docs: optimize deps when dev (#5434)

This commit is contained in:
三咲智子 2022-01-18 06:33:53 +08:00 committed by GitHub
parent d2e482c592
commit 1d48642436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 50 deletions

View File

@ -3,3 +3,4 @@ dist
pnpm-lock.yaml
CHANGELOG.en-US.md
!.*
docs/components.d.ts

View File

@ -3,3 +3,4 @@ node_modules
coverage
CHANGELOG.en-US.md
pnpm-lock.yaml
docs/components.d.ts

16
docs/components.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/vue-next/pull/3399
declare module 'vue' {
export interface GlobalComponents {
IRiCodeLine: typeof import('~icons/ri/code-line')['default']
IRiExternalLinkLine: typeof import('~icons/ri/external-link-line')['default']
IRiFileCopy2Line: typeof import('~icons/ri/file-copy2-line')['default']
IRiGithubLine: typeof import('~icons/ri/github-line')['default']
IRiPlayCircleLine: typeof import('~icons/ri/play-circle-line')['default']
IRiTranslate2: typeof import('~icons/ri/translate2')['default']
}
}
export { }

View File

@ -2,11 +2,14 @@ import path from 'path'
import Inspect from 'vite-plugin-inspect'
import { defineConfig } from 'vite'
import WindiCSS from 'vite-plugin-windicss'
import glob from 'fast-glob'
import Components from 'unplugin-vue-components/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import { getPackageDependencies } from '../build/utils/pkg'
import { epPackage } from '../build/utils/paths'
import { projRoot } from './.vitepress/utils/paths'
import type { Alias } from 'vite'
@ -24,60 +27,67 @@ if (process.env.DOC_ENV !== 'production') {
)
}
export default defineConfig({
server: {
host: true,
fs: {
strict: true,
allow: [projRoot],
export default async () => {
const deps = getPackageDependencies(epPackage)
const optimizeDeps = [
'vue',
'@vue/shared',
'markdown-it',
'clipboard-copy',
'axios',
'nprogress',
...deps,
]
optimizeDeps.push(
...(
await glob(['lodash/[!_]*.js', 'dayjs/plugin/*.js'], {
cwd: path.resolve(projRoot, 'node_modules'),
onlyFiles: true,
})
).map((file) => file.replace(/\.js$/, ''))
)
return defineConfig({
server: {
host: true,
fs: {
strict: true,
allow: [projRoot],
},
},
},
resolve: {
alias,
},
build: {
rollupOptions: {
output: {
manualChunks: {
windicss: ['windicss'],
resolve: {
alias,
},
build: {
rollupOptions: {
output: {
manualChunks: {
windicss: ['windicss'],
},
},
},
},
},
plugins: [
// https://github.com/antfu/unplugin-vue-components
Components({
// custom resolvers
resolvers: [
// auto import icons
// https://github.com/antfu/unplugin-icons
IconsResolver(),
],
}),
plugins: [
// https://github.com/antfu/unplugin-vue-components
Components({
// custom resolvers
resolvers: [
// auto import icons
// https://github.com/antfu/unplugin-icons
IconsResolver(),
],
}),
// https://github.com/antfu/unplugin-icons
Icons({
autoInstall: true,
}),
// https://github.com/antfu/unplugin-icons
Icons({
autoInstall: true,
}),
WindiCSS(),
Inspect(),
],
optimizeDeps: {
include: [
'vue',
'markdown-it',
'clipboard-copy',
'@vueuse/core',
'axios',
'nprogress',
'@element-plus/icons-vue',
'dayjs',
'memoize-one',
'async-validator',
'lodash',
'@popperjs/core',
'normalize-wheel-es',
WindiCSS(),
Inspect(),
],
},
})
optimizeDeps: {
include: optimizeDeps,
},
})
}