-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathvite.config.ts
69 lines (65 loc) · 1.91 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
65
66
67
68
69
import * as path from 'path';
import {
createStyleImportPlugin,
NutuiResolve,
} from 'vite-plugin-style-import';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import { defineConfig, loadEnv, ConfigEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
const alias: Record<string, string> = {
'@': path.resolve(__dirname, 'src'),
};
const viteConfig = defineConfig((mode: ConfigEnv) => {
const env = loadEnv(mode.mode, process.cwd());
return {
plugins: [
vue(),
createStyleImportPlugin({
resolves: [NutuiResolve()],
}),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
symbolId: 'icon-[dir]-[name]',
customDomId: '__svg__icons__dom__',
}),
],
root: process.cwd(),
resolve: { alias },
base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
hmr: true,
server: {
port: env.VITE_PORT as unknown as number,
open: env.VITE_OPEN,
},
build: {
outDir: 'dist',
sourcemap: false,
chunkSizeWarningLimit: 1500,
rollupOptions: {
output: {
entryFileNames: `assets/[name].${new Date().getTime()}.js`,
chunkFileNames: `assets/[name].${new Date().getTime()}.js`,
assetFileNames: `assets/[name].${new Date().getTime()}.[ext]`,
compact: true,
manualChunks: {
vue: ['vue', 'vue-router', 'pinia'],
},
},
},
},
css: {
preprocessorOptions: {
scss: {
// 配置 自定义覆盖主题 和 nutui 全局 scss 变量
additionalData: `@import "@/assets/custom_theme_variables.scss";@import "@nutui/nutui/dist/styles/variables-jdt.scss";`,
},
},
},
define: {
__VUE_I18N_FULL_INSTALL__: true,
__VUE_I18N_LEGACY_API__: false,
__INTLIFY_PROD_DEVTOOLS__: false,
},
};
});
export default viteConfig;