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
70
71
72
73
74
75
76
77
78
79
80
81
| import vue from '@vitejs/plugin-vue';
| import { resolve } from 'path';
| import { defineConfig, loadEnv, ConfigEnv } from 'vite';
| import postCssPxToRem from "postcss-pxtorem"
| const pathResolve = (dir: string): any => {
| return resolve(__dirname, '.', dir);
| };
|
| const alias: Record<string, string> = {
| '/@': pathResolve('./src/'),
| 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
| };
|
| const viteConfig = defineConfig((mode: ConfigEnv) => {
| const env = loadEnv(mode.mode, process.cwd());
| return {
| publicPath: './',
| plugins: [vue()],
| root: process.cwd(),
| resolve: { alias },
| assetsInclude: ['**/*.JPG'],
| base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
| hmr: true,
| optimizeDeps: {
| include: ['element-plus/lib/locale/lang/zh-cn', 'element-plus/lib/locale/lang/en', 'element-plus/lib/locale/lang/zh-tw']
| },
| server: {
| host: '0.0.0.0',
| port: env.VITE_PORT as unknown as number,
| open: env.VITE_OPEN,
| proxy: {
| '/gitee': {
| target: 'https://gitee.com',
| ws: true,
| changeOrigin: true,
| rewrite: (path) => path.replace(/^\/gitee/, '')
| }
| }
| },
| build: {
| outDir: 'dist',
| sourcemap: false,
| chunkSizeWarningLimit: 2000,
| 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'],
| echarts: ['echarts']
| }
| }
| }
| },
| css: {
| postcss: {
| plugins: [
| postCssPxToRem({
| rootValue: 37.5, // 1rem的大小(控制1rem的大小 点位:px)
| propList: ["*"], // 需要转换的属性,这里选择全部都进行转换
| // exclude: (e:any) => { // 不包含
| // if (/src(\\|\/)views(\\|\/)bigScreen(\\|\/)index/.test(e)||/src(\\|\/)views(\\|\/)bigScreen(\\|\/)fullScreen(\\|\/)index/.test(e)||/src(\\|\/)views(\\|\/)bigScreen(\\|\/)components(\\|\/)screen/.test(e)||/src(\\|\/)views(\\|\/)loginPage(\\|\/)loginPage/.test(e)||/src(\\|\/)views(\\|\/)loginPage(\\|\/)component(\\|\/)accountLogin/.test(e)) { // 指定生效页面(正则)
| // return false;
| // }
| // return true;
| // }
| }),
| ],
| },
| },
| define: {
| __VUE_I18N_LEGACY_API__: JSON.stringify(false),
| __VUE_I18N_FULL_INSTALL__: JSON.stringify(false),
| __INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false)
| }
| };
| });
|
| export default viteConfig;
|
|