-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
56 lines (55 loc) · 1.34 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
import { defineConfig, loadEnv } from 'vite';
import { resolve } from 'path';
import { createVitePlugins } from './build/vite';
import { wrapperEnv } from './build/utils';
function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir);
}
export default defineConfig(({ mode, command }) => {
const root = process.cwd();
const env = loadEnv(mode, root);
const viteEnv = wrapperEnv(env);
const { VITE_PORT, VITE_PUBLIC_PATH, VITE_DROP_CONSOLE } = viteEnv;
const isBuild = command === 'build';
return {
base: VITE_PUBLIC_PATH,
root,
server: {
port: VITE_PORT,
host: true,
},
resolve: {
alias: [
{
find: 'vue-i18n',
replacement: 'vue-i18n/dist/vue-i18n.cjs.js',
},
{
find: /\/@\//,
replacement: pathResolve('src') + '/',
},
{
find: /\/#\//,
replacement: pathResolve('types') + '/',
},
{
find: /\/~\//,
replacement: pathResolve('electron') + '/',
},
],
},
esbuild: {
pure: VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [],
},
build: {
cssTarget: 'chrome80',
chunkSizeWarningLimit: 2000,
},
css: {
preprocessorOptions: {
scss: {},
},
},
plugins: createVitePlugins(viteEnv, isBuild),
};
});