element-plus/play/vite.config.ts
三咲智子 ca7bcfe9b3
feat: add defineOptions for script-setup (#5932)
* feat: add unplugin-vue-define-options

* feat: add jest support
2022-02-11 11:39:49 +08:00

57 lines
1.5 KiB
TypeScript

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 mkcert from 'vite-plugin-mkcert'
import glob from 'fast-glob'
import DefineOptions from 'unplugin-vue-define-options/vite'
import { epRoot, pkgRoot, projRoot, epPackage } from '../build/utils/paths'
import { getPackageDependencies } from '../build/utils/pkg'
import './vite.init'
export default defineConfig(async () => {
const { dependencies } = getPackageDependencies(epPackage)
const optimizeDeps = (
await glob(['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,
https: !!process.env.HTTPS,
},
plugins: [
vue(),
DefineOptions(),
Components({
include: `${__dirname}/**`,
resolvers: ElementPlusResolver({ importStyle: 'sass' }),
dts: false,
}),
mkcert(),
Inspect(),
],
optimizeDeps: {
include: ['vue', '@vue/shared', ...dependencies, ...optimizeDeps],
},
}
})