-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvue.config.js
92 lines (92 loc) · 2.83 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
89
90
91
92
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const productionGzipExtensions = ['js', 'css'];
const path = require('path');
const shell = require('shelljs');
shell.cp(process.cwd() + '/config/' + process.env.BUILD_ENV + '.js', process.cwd() + '/src/config.js');
console.log('use config file : ' + process.cwd() + '/config/' + process.env.BUILD_ENV + '.js');
module.exports = {
chainWebpack: config => {
config.resolve.alias
.set('@', path.resolve(__dirname, 'src'));
},
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new CompressionWebpackPlugin({
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 1024,
minRatio: 0.8
}));
}
// else {
// config.plugins.push(new WebpackBundleAnalyzer());
// }
// config.devtool = false;
config.performance = {
maxAssetSize: 200000,
maxEntrypointSize: 400000
};
config.optimization = {
splitChunks: {
chunks: 'all',
minSize: 30000,
maxAsyncRequests: 5,
maxInitialRequests: 5,
cacheGroups: {
'nerve-sdk-js': {
test: /[\\/]node_modules[\\/](nerve-sdk-js)[\\/]/,
name: 'nerve-sdk-js',
priority: 2
},
'nuls-sdk-js': {
test: /[\\/]node_modules[\\/](nuls-sdk-js)[\\/]/,
name: 'nuls-sdk-js',
priority: 2
},
vendors: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
priority: 1,
reuseExistingChunk: true
}
}
}
};
config.externals = {
'vue': 'Vue',
'vue-router': 'VueRouter',
'vuex': 'Vuex',
'element-ui': 'ELEMENT',
'vant': 'vant',
// 'ethers': 'ethers',
'web3': 'Web3',
'vue-i18n': 'VueI18n',
'moment': 'moment'
};
config.plugins.push(
new NodePolyfillPlugin({
excludeAliases: ['console']
})
);
},
devServer: {
port: 8001,
host: '0.0.0.0',
compress: true,
// disableHostCheck: true, // webpack4.0 开启热更新
https: false, // https: {type:Boolean}
open: true, // 配置自动启动浏览器
proxy: { // 配置跨域处理
'/nabox-api': {
// target: 'http://192.168.1.204:8083', // 周维
target: 'http://47.236.243.122:19001', // 测试环境
// target: ' https://beta.serviceapi.nabox.io', // 测试环境
// target: 'https://api.v2.nabox.io/', // 主网环境
// target: 'http://naboxapi.niels.wang', // 主网环境
// target: 'http://thowtyvo.ipyingshe.net', // 远程环境
changeOrigin: true // 是否跨域
}
}
}
};