-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
67 lines (66 loc) · 2.26 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
// 代码压缩
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
// gzip压缩
const CompressionWebpackPlugin = require('compression-webpack-plugin')
// 是否为生产环境
const isProduction = process.env.NODE_ENV !== 'development'
// 本地环境是否需要使用cdn
const devNeedCdn = true
module.exports = {
productionSourceMap: false,
// 修改 src 目录 为 examples 目录
pages: {
index: {
entry: 'examples/main.js',
template: 'public/index.html',
filename: 'index.html'
}
},
// 扩展 webpack 配置,使 packages 加入编译
chainWebpack: config => {
config.module
.rule('js')
.include
.add('/packages')
.end()
.use('babel')
.loader('babel-loader')
.loader('sass-loader')
.tap(options => {
// 修改它的选项...
return options
})
},
// configureWebpack: config => {
// // 代码压缩
// config.plugins.push(
// new UglifyJsPlugin({
// uglifyOptions: {
// //生产环境自动删除console
// compress: {
// warnings: false, // 若打包错误,则注释这行
// drop_debugger: true,
// drop_console: true,
// pure_funcs: ['console.log']
// }
// },
// sourceMap: false,
// parallel: true
// })
// )
// // gzip压缩
// const productionGzipExtensions = ['html', 'js', 'css']
// config.plugins.push(
// new CompressionWebpackPlugin({
// filename: '[path].gz[query]',
// algorithm: 'gzip',
// test: new RegExp(
// '\\.(' + productionGzipExtensions.join('|') + ')$'
// ),
// threshold: 10240, // 只有大小大于该值的资源会被处理 10240
// minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
// deleteOriginalAssets: false // 删除原文件
// })
// )
// }
}