forked from now1then/vue-h5-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
60 lines (56 loc) · 1.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
const path = require('path');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
// require('vue-cli-plugin-style-resources-loader')
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
devServer: {
// open: true, // 是否自动打开浏览器页面
// host: 'localhost', // 指定使用一个 host,默认是 localhost
// port: 8080, // 端口地址
proxy: {
'^/baidu': {
target: 'http://10.59.81.31:8088',
changeOrigin: true,
pathRewrite: {
'^/baidu': ''
}
},
'^/default': {
target: 'http://10.59.81.31:8088',
changeOrigin: true,
pathRewrite: {
'^/default': ''
}
},
}
},
publicPath: './', // 打包后引用的资源路径
// outputDir: 'dist', // 打包目录
configureWebpack: (config) => { // webpack自定义配置
// 生产环境打包分析体积
if (process.env.NODE_ENV === 'production' && process.env.npm_config_report) {
return {
plugins: [
new BundleAnalyzerPlugin()
]
}
}
},
chainWebpack: config => { // CLI内部webpack配置
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
},
}
// 全局样式 变量、函数
function addStyleResource (rule) {
rule.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
resolve('src/styles/variables.less'),
resolve('src/styles/mixin.less'),
],
})
}