element-plus/play/vite.config.ts

58 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-10-26 17:09:14 +08:00
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Inspect from 'vite-plugin-inspect'
import glob from 'fast-glob'
import { epRoot, pkgRoot, projRoot } from '../build/utils/paths'
import './vite.init'
export default defineConfig(async () => {
const optimizeDeps = (
await glob(['lodash/*.js', 'dayjs/(locale|plugin)/*.js'], {
cwd: path.resolve(projRoot, 'node_modules'),
})
).map((dep) => dep.replace(/\.js$/, ''))
return {
resolve: {
alias: [
{
find: /^element-plus(\/(es|lib))?$/,
replacement: path.resolve(epRoot, 'index.ts'),
},
{
find: /^element-plus\/(es|lib)\/(.*)$/,
replacement: `${pkgRoot}/$2`,
},
],
},
server: {
host: true,
},
plugins: [
vue(),
Components({
include: `${__dirname}/**`,
resolvers: ElementPlusResolver({ importStyle: 'sass' }),
}),
Inspect(),
2021-10-26 17:09:14 +08:00
],
optimizeDeps: {
include: [
'@vue/shared',
'@vueuse/core',
'async-validator',
'memoize-one',
'normalize-wheel-es',
'@popperjs/core',
'dayjs',
'@element-plus/icons-vue',
...optimizeDeps,
],
},
}
})