-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.js
68 lines (56 loc) · 1.42 KB
/
vite.config.js
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
65
66
67
68
/* eslint-disable */
import legacyPlugin from '@vitejs/plugin-legacy';
import * as path from 'path';
import vuePlugin from '@vitejs/plugin-vue';
import viteCompression from 'vite-plugin-compression';
// @see https://cn.vitejs.dev/config/
export default ({
command,
mode
}) => {
let rollupOptions = {};
let optimizeDeps = {};
let alias = {}
let proxy = {}
// todo 替换为原有变量
let define = {
'process.env.NODE_ENV': command === 'serve' ? '"development"' : '"production"',
}
let esbuild = {}
return {
base: './', // index.html文件所在位置
root: './', // js导入的资源路径,src
resolve: {
alias,
},
define: define,
server: {
// 代理
proxy,
},
build: {
target: 'es2015',
minify: 'terser', // 是否进行压缩,boolean | 'terser' | 'esbuild',默认使用terser
manifest: false, // 是否产出maifest.json
sourcemap: false, // 是否产出soucemap.json
outDir: 'build', // 产出目录
rollupOptions,
},
esbuild,
optimizeDeps,
plugins: [
viteCompression(),
legacyPlugin({
targets: ['Android > 39', 'Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15'],
}), vuePlugin(),
],
css: {
preprocessorOptions: {
less: {
// 支持内联 JavaScript
javascriptEnabled: true,
},
},
},
};
};