-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
95 lines (84 loc) · 2.36 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
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ZipWebpackPlugin = require('zip-webpack-plugin');
const path = require('path');
const packageInfo = require('./package.json');
const productionMode = process.env.NODE_ENV === 'production';
// Generate pages object
const pages = {};
const chromeName = ['popup', 'options'];
chromeName.forEach(name => {
pages[name] = {
entry: `src/${name}/index.js`,
template: path.resolve(`src/${name}/index.html`),
filename: `${name}.html`,
chunks: ['chunk-vendors', 'chunk-common', name],
};
});
const folderName = productionMode ? 'build' : 'dist';
const copyFiles = [
{
from: path.resolve(`src/manifest/chrome/manifest.${productionMode ? 'production' : 'development'}.json`),
to: `${path.resolve(folderName)}/manifest.json`,
},
];
copyFiles.push({
from: path.resolve('src/assets'),
to: path.resolve(folderName),
});
process.env.VUE_APP_VERSION = productionMode ? packageInfo.version : packageInfo.version + ' (Dev)';
module.exports = {
outputDir: folderName,
pages,
filenameHashing: false,
productionSourceMap: false,
lintOnSave: 'warning',
configureWebpack: config => {
config.plugins.push(
new CopyWebpackPlugin({
patterns: copyFiles,
})
);
if (productionMode) {
Object.assign(config.optimization.minimizer[0].options.terserOptions.compress, {
warnings: false,
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log'],
});
config.plugins.push(
new ZipWebpackPlugin({
path: path.resolve('archive'),
filename: `${packageInfo.name}_v${packageInfo.version}.zip`,
})
);
} else {
config.devtool = 'cheap-module-source-map';
}
// 关闭 webpack 的性能提示
config.performance = {
hints: false,
};
},
css: {
loaderOptions: {
less: {
lessOptions: {
/**
* 变量列表:
* https://github.com/vueComponent/ant-design-vue/blob/master/components/style/themes/default.less
*/
modifyVars: {
'text-color': 'rgba(0, 0, 0, 0.85)',
},
javascriptEnabled: true,
},
},
},
},
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: [path.resolve('src/less/variables.less')],
},
},
};