-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
77 lines (77 loc) · 2.61 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
const webpack = require('webpack')
//const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const Timestamp = new Date().getTime(); //当前时间为了防止打包缓存不刷新,所以给每个js文件都加一个时间戳
module.exports = {
devServer: {
port: 8089,
// disableHostCheck: true,
// proxy: { //服务器代理,解决前后端接口跨域问题
// '/': { //这里写需要以什么开头的地址才会去代理
// //1、这里写以什么开头的地址才会去代理;
// //注意/abc是前端自己自定义的参数名称或者是实际的请求地址的参数名称
// //2、在项目中'只要是'/abc'开头的请求地址才用代理.
// //所以你的接口就要这么写 /abc/xx/xx.
// //3、如果要代理所有的请求地址就写为"/"
// target: 'http://xxx.xxxxxx.xxx:50003/',
// ws: false, //是否代理websockets
// // pathRewrite: { //如果上面的/abc不是实际的请求地址的开头参数那么在这里就要进行冲洗写实际请求时的地址名称
// // '^/a': '/mark'
// // }
// }
// }
},
css: {
extract: {
//打包后的css带版本号,不改变文件名
// filename: 'css/[name].css?v=' + Timestamp,
// chunkFilename : 'css/[name].css?v=' + Timestamp
//打包后的css带版本号,文件名会改变
filename: 'css/[name].[' + Timestamp + '].css',
chunkFilename: 'css/[name].[' + Timestamp + '].css'
},
loaderOptions: {
sass: {
prependData: `@import "@/common/css/mixin.scss";`
}
}
},
configureWebpack: {
//关闭 webpack 的性能提示
performance: {
hints: false
},
output: { // 输出重构 打包编译后的 文件名称 【模块名称.时间戳】
filename: `js/[name].${process.env.VUE_APP_CURRENTMODE}.${Timestamp}.js`,
chunkFilename: `js/[name].${process.env.VUE_APP_CURRENTMODE}.${Timestamp}.js`
},
// optimization: {
// minimizer: [new UglifyJsPlugin({
// sourceMap: true, //是否需要map文件
// uglifyOptions: {
// output: {
// comments: false // 去掉注释
// },
// warnings: false,
// compress: {
// drop_console: true,
// }
// },
// })],
// },
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/) //忽略 moment 的本地化内容
]
},
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
chainWebpack: (config) => {
config.module
.rule("eslint")
.use("eslint-loader")
.loader("eslint-loader")
.tap(options => {
options.fix = true; //设置自动修复eslint
return options;
})
}
}