mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-27 03:01:14 +08:00
bb939c6a58
* refactor(build): move to internal package * ci: fix * chore: fix * fix: docs * chore: add fast-glob to root package * chore: fix PR comments * build: add tsx * refactor: re-organize * refactor: improve log
81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
import path from 'path'
|
|
import { defineConfig, loadEnv } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
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 esbuild from 'rollup-plugin-esbuild'
|
|
import {
|
|
epRoot,
|
|
pkgRoot,
|
|
projRoot,
|
|
epPackage,
|
|
getPackageDependencies,
|
|
} from '@element-plus/build'
|
|
import './vite.init'
|
|
|
|
const esbuildPlugin = () => ({
|
|
...esbuild({
|
|
target: 'chrome64',
|
|
include: /\.vue$/,
|
|
loaders: {
|
|
'.vue': 'js',
|
|
},
|
|
}),
|
|
enforce: 'post',
|
|
})
|
|
|
|
export default defineConfig(async ({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
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: !!env.HTTPS,
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
esbuildPlugin(),
|
|
vueJsx(),
|
|
DefineOptions(),
|
|
Components({
|
|
include: `${__dirname}/**`,
|
|
resolvers: ElementPlusResolver({ importStyle: 'sass' }),
|
|
dts: false,
|
|
}),
|
|
mkcert(),
|
|
Inspect(),
|
|
],
|
|
|
|
optimizeDeps: {
|
|
include: ['vue', '@vue/shared', ...dependencies, ...optimizeDeps],
|
|
},
|
|
esbuild: {
|
|
target: 'chrome64',
|
|
},
|
|
}
|
|
})
|