-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
88 lines (83 loc) · 2.29 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
const CompressionPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
const SentryPlugin = require('@sentry/webpack-plugin')
module.exports = {
publicPath: '/vue-blog/',
outputDir: 'dist',
assetsDir: undefined,
runtimeCompiler: undefined,
productionSourceMap: true,
parallel: undefined,
css: {
sourceMap: true
},
devServer: {
proxy: {
'/api': {
target: 'http://localhost:3000',
ws: true,
changeOrigin: true
}
}
},
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
var externals = {
vue: 'Vue',
axios: 'axios',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter',
vuex: 'Vuex'
}
config.externals(externals)
const cdn = {
css: [
// element-ui css
'https://unpkg.com/[email protected]/lib/theme-chalk/index.css'
],
js: [
// vue
'https://cdn.jsdelivr.net/npm/[email protected]',
// vue-router
'https://unpkg.com/[email protected]/dist/vue-router.min.js',
// vuex
'https://unpkg.com/[email protected]',
// axios
'https://unpkg.com/[email protected]/dist/axios.min.js',
// element-ui js
'https://unpkg.com/[email protected]/lib/index.js'
]
}
config.plugin('html')
.tap(args => {
args[0].cdn = cdn
return args
})
}
},
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 生产环境
config.plugins.push(
new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
)
config.plugins.push(
new SentryPlugin({
include: './dist/',
release: process.env.RELEASE_VERSION, // 一致的版本号
configFile: 'sentry.properties', // 不用改
ignore: ['node_modules', 'webpack.config.js'],
urlPrefix: '~/vue-blog/' // 这里指的你项目需要观测的文件如果你的项目有publicPath这里加上就对了
})
)
} else {
// 开发环境
}
}
}