forked from hangjob/vue-bag-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
64 lines (61 loc) · 2.24 KB
/
vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { defineConfig, loadEnv } from 'vite'
import setProBuild from './build/pro'
import setLibBuild from './build/lib'
import setUtilsBuild from './build/utils'
import setWebBuild from './build/web'
import createVitePlugins from './build/plugin/index'
import { configServer } from './build/server/index'
import { configCss } from './build/css/index'
const path = require('path')
export default ({ mode }: { mode: any }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
let build: any = {
minify: false, // 跟踪这个警告[https://github.com/element-plus/element-plus/issues/3219#issuecomment-960374776]
outDir: process.env.VITE_MODE, //打包文件名称
assetsDir: 'assets', //打包静态文件的存储地址
chunkSizeWarningLimit: 500,
}
console.log('mode', mode)
if (mode === 'development') {
const { rollupOptions } = setProBuild()
build.rollupOptions = rollupOptions
}
if (mode == 'production') {
const { rollupOptions, terserOptions } = setProBuild()
build.rollupOptions = rollupOptions
build.terserOptions = terserOptions
}
if (mode === 'lib') {
const { emptyOutDir, lib, rollupOptions } = setLibBuild()
build.emptyOutDir = emptyOutDir
build.lib = lib
build.rollupOptions = rollupOptions
}
if (mode === 'web') {
const { emptyOutDir, lib, rollupOptions } = setWebBuild()
build.emptyOutDir = emptyOutDir
build.lib = lib
build.rollupOptions = rollupOptions
}
if (mode === 'utils') {
const { emptyOutDir, lib } = setUtilsBuild()
build.emptyOutDir = emptyOutDir
build.lib = lib
}
return defineConfig({
base: '/',
plugins: createVitePlugins({ variables: process.env }),
publicDir: 'public',
resolve: {
alias: {
// 如果报错__dirname找不到,需要安装node,执行yarn add @types/node --save-dev
'@www': path.resolve(__dirname, 'www'),
'@': path.resolve(__dirname, 'src'),
'__ROOT__': path.resolve(__dirname, ''),
},
},
server: configServer(),
css: configCss(),
build,
})
}