mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-27 02:01:15 +08:00
92 lines
2.1 KiB
TypeScript
92 lines
2.1 KiB
TypeScript
import path from 'path'
|
|
import Inspect from 'vite-plugin-inspect'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import DefineOptions from 'unplugin-vue-define-options/vite'
|
|
import UnoCSS from 'unocss/vite'
|
|
import mkcert from 'vite-plugin-mkcert'
|
|
import glob from 'fast-glob'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import Components from 'unplugin-vue-components/vite'
|
|
import Icons from 'unplugin-icons/vite'
|
|
import IconsResolver from 'unplugin-icons/resolver'
|
|
import {
|
|
epPackage,
|
|
getPackageDependencies,
|
|
projRoot,
|
|
} from '@element-plus/build'
|
|
import type { Alias } from 'vite'
|
|
|
|
const alias: Alias[] = []
|
|
if (process.env.DOC_ENV !== 'production') {
|
|
alias.push(
|
|
{
|
|
find: /^element-plus(\/(es|lib))?$/,
|
|
replacement: path.resolve(projRoot, 'packages/element-plus/index.ts'),
|
|
},
|
|
{
|
|
find: /^element-plus\/(es|lib)\/(.*)$/,
|
|
replacement: `${path.resolve(projRoot, 'packages')}/$2`,
|
|
}
|
|
)
|
|
}
|
|
|
|
export default defineConfig(async ({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
const { dependencies } = getPackageDependencies(epPackage)
|
|
const optimizeDeps = [
|
|
'vue',
|
|
'@vue/shared',
|
|
'markdown-it',
|
|
'clipboard-copy',
|
|
'axios',
|
|
'nprogress',
|
|
...dependencies,
|
|
]
|
|
optimizeDeps.push(
|
|
...(
|
|
await glob(['dayjs/plugin/*.js'], {
|
|
cwd: path.resolve(projRoot, 'node_modules'),
|
|
onlyFiles: true,
|
|
})
|
|
).map((file) => file.replace(/\.js$/, ''))
|
|
)
|
|
|
|
return {
|
|
server: {
|
|
host: true,
|
|
https: !!env.HTTPS,
|
|
fs: {
|
|
allow: [projRoot],
|
|
},
|
|
},
|
|
resolve: {
|
|
alias,
|
|
},
|
|
plugins: [
|
|
vueJsx(),
|
|
DefineOptions(),
|
|
|
|
// 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,
|
|
}),
|
|
UnoCSS(),
|
|
Inspect(),
|
|
mkcert(),
|
|
],
|
|
optimizeDeps: {
|
|
include: optimizeDeps,
|
|
},
|
|
}
|
|
})
|