-
Notifications
You must be signed in to change notification settings - Fork 61
/
vue.config.js
65 lines (62 loc) · 1.86 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
const { defineConfig } = require('@vue/cli-service')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
const config = require('./config/index')
const isDev = config.isDev
const publicPath = config.publicPath
const indexPath = config.indexPath
const externals = {
vue: 'Vue',
vuex: 'Vuex',
'vue-router': 'VueRouter',
'element-ui': 'ELEMENT',
'view-design': 'iView'
}
const cdn = {
externals,
css: [
'https://unpkg.com/element-ui/lib/theme-chalk/index.css',
'https://unpkg.com/view-design/dist/styles/iview.css'
],
js: [
'https://cdn.staticfile.org/vue/2.6.12/vue.min.js',
'https://cdn.staticfile.org/vuex/3.5.1/vuex.min.js',
'https://cdn.staticfile.org/vue-router/3.0.3/vue-router.min.js',
'https://unpkg.com/element-ui/lib/index.js',
'https://unpkg.com/view-design/dist/iview.min.js'
]
}
module.exports = defineConfig({
transpileDependencies: true,
publicPath,
indexPath,
productionSourceMap: config.isDev,
css: {
extract: true,
sourceMap: false,
loaderOptions: {
scss: {
additionalData: `@import "@/style/variable.scss";@import "@/style/mixin.scss";`
}
}
},
configureWebpack: config => {
config.optimization.nodeEnv = false
const com = new CompressionWebpackPlugin({
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
config.plugins.push(com)
if (!isDev) {
config.externals = cdn.externals
}
},
chainWebpack(config) {
config.plugin('html').tap(args => {
if (!isDev) args[0].cdn = cdn
return args
})
}
})