-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
75 lines (73 loc) · 1.9 KB
/
vite.config.ts
File metadata and controls
75 lines (73 loc) · 1.9 KB
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
/*
* vite配置
*
* @Author: 1024创新实验室-主任:卓大
* @Date: 2022-05-02 23:44:56
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 ( https://1024lab.net ),2012-2022
*/
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';
import { defineConfig, loadEnv } from 'vite';
import createVitePlugins from './src/vite/plugins';
const pathResolve = (dir) => {
return resolve(__dirname, '.', dir);
};
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd());
const { VITE_APP_ENV } = env;
return {
base: process.env.NODE_ENV === 'production' ? '/manages/' : '/',
root: process.cwd(),
resolve: {
alias: [
// 国际化替换
{
find: 'vue-i18n',
replacement: 'vue-i18n/dist/vue-i18n.cjs.js',
},
// 绝对路径重命名:/@/xxxx => src/xxxx
{
find: /\/@\//,
replacement: pathResolve('src') + '/',
},
{
find: /^~/,
replacement: '',
},
],
},
// 服务端渲染
server: {
host: '0.0.0.0',
port: 8080,
},
plugins: [createVitePlugins(env, command === 'build')],
optimizeDeps: {
include: ['ant-design-vue/es/locale/zh_CN', 'dayjs/locale/zh-cn', 'ant-design-vue/es/locale/en_US'],
exclude: ['vue-demi'],
},
build: {
brotliSize: false,
chunkSizeWarningLimit: 2000,
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import (reference) "${resolve('src/theme/index.less')}";`,
},
javascriptEnabled: true,
},
scss: {
additionalData: `@use "src/assets/styles/index.scss" as *;`
}
},
},
define: {
__INTLIFY_PROD_DEVTOOLS__: false,
'process.env': process.env,
},
}
});