-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
125 lines (120 loc) · 3.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const path = require('path');
const webpack = require('webpack');
const address = require('address');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const createThemeColorReplacerPlugin = require('./plugin.config');
const { name } = require('./package');
const needHost = address.ip() || 'localhost';
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
publicPath: process.env.VUE_APP_BASE_URL,
devServer: {
// host: needHost,
open: true, // process.platform === 'win32'
port: 8080,
hot: true,
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
outputDir: 'site',
css: {
extract: process.env.NODE_ENV == 'production',
sourceMap: process.env.NODE_ENV !== 'production',
loaderOptions: {
less: {
additionalData: `@import "~@/assets/less/var.less";`,
lessOptions: {
modifyVars: {
// 'primary-color': '#1890ff',
// 'link-color': '#1DA57A',
'border-radius-base': '2px',
},
javascriptEnabled: true,
},
},
},
},
lintOnSave: false,
productionSourceMap: process.env.NODE_ENV !== 'production',
chainWebpack: config => {
config.resolve.alias
.set('COMPONENTS', resolve('src/components'))
.set('VIEWS', resolve('src/views'))
.set('REQUEST', resolve('src/request'))
.set('ASSETS', resolve('src/assets'))
.set('UTILS', resolve('src/utils'));
config.plugin('provide').use(webpack.ProvidePlugin, [
{
// other modules
introJs: ['intro.js'],
},
]);
/* config.module
.rule("images")
.use("image-webpack-loader")
.loader("image-webpack-loader")
.options({
bypassOnDebug: true
})
.end(); */
},
configureWebpack: () => ({
output: {
library: `${name}-[name]`,
libraryTarget: 'umd', // 把微应用打包成 umd 库格式
jsonpFunction: `webpackJsonp_${name}`,
},
performance: {
// 关闭webpack性能提示,主要用在打包时
hints: false,
},
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
chunks: 'all',
test: /node_modules/,
name: 'vendor',
minChunks: 1,
maxInitialRequests: 5,
minSize: 0,
priority: 100,
},
common: {
chunks: 'all',
test: /[\\/]src[\\/]js[\\/]/,
name: 'common',
minChunks: 2,
maxInitialRequests: 5,
minSize: 0,
priority: 60,
},
styles: {
name: 'styles',
test: /\.(sa|sc|c|le)ss$/,
chunks: 'all',
enforce: true,
},
runtimeChunk: {
name: 'manifest',
},
},
},
},
plugins: [
createThemeColorReplacerPlugin(),
// new CompressionWebpackPlugin({
// filename: '[path].gz[query]',
// algorithm: 'gzip',
// test: /\.js$|\.html$|\.json$|\.css/,
// threshold: 0, // 只有大小大于该值的资源会被处理
// minRatio: 0.8, // 只有压缩率小于这个值的资源才会被处理
// deleteOriginalAssets: true // 删除原文件
// })
],
}),
};