-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvue.config.js
109 lines (98 loc) · 2.82 KB
/
vue.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const IS_PROD = process.env.NODE_ENV === 'production'
const assetsCDN = {
externals: {
vue: 'Vue',
'vue-router': 'VueRouter',
vuex: 'Vuex',
axios: 'axios',
},
css: [],
js: [
'//cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js',
'//cdn.jsdelivr.net/npm/[email protected]/dist/vue-router.min.js',
'//cdn.jsdelivr.net/npm/[email protected]/dist/vuex.min.js',
'//cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js',
],
}
module.exports = {
publicPath: process.env.VUE_APP_PUBLIC_PATH,
outputDir: process.env.VUE_APP_OUTPUT_DIR,
productionSourceMap: false,
devServer: {
host: '0.0.0.0',
proxy: {
[process.env.VUE_APP_REQUEST_BASE_URL]: {
target: process.env.VUE_APP_BASE_API,
changeOrigin: true,
},
},
},
css: {
loaderOptions: {
less: {
lessOptions: {
modifyVars: {
'primary-color': '#6485ff',
'success-color': '#57df9c',
'warning-color': '#fdac41',
'error-color': '#ff5b5c',
'info-color': '#6485ff',
'processing-color': '#6485ff',
'text-color': '#475f7b',
'font-size-base': '15px',
'border-radius-base': '6px',
'btn-border-radius-base': '4px',
'btn-border-radius-sm': '4px',
'font-family':
"-apple-system, Rubik, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",
},
javascriptEnabled: true,
},
},
scss: { additionalData: '@import "@/assets/scss/variables.scss";' },
postcss: {
plugins: [require('tailwindcss')('./tailwind.config.js')],
},
},
},
chainWebpack: (config) => {
config.resolve.alias.set('@img', '@/assets/images').set('@comp', '@/components')
config.plugin('html').tap((args) => {
args[0].title = process.env.VUE_APP_PAGE_TITLE
if (IS_PROD) {
args[0].cdn = assetsCDN
}
return args
})
},
configureWebpack: (config) => {
config.plugins.push(
new AntdDayjsWebpackPlugin({
preset: 'antdv3',
})
)
config.optimization = {
splitChunks: {
chunks: 'all',
},
}
if (IS_PROD) {
config.plugins.push(
new CompressionPlugin({
test: /\.js$|\.html$|\.css/,
threshold: 8192,
})
)
if (process.env.VUE_APP_MODE === 'analyze') {
config.plugins.push(new BundleAnalyzerPlugin())
}
config.externals = {
...config.externals,
...assetsCDN.externals,
}
}
},
}