webpack.prod.config.js
1.18 KB
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
'use strict';
const os = require('os');
const path = require('path');
const shelljs = require('shelljs');
const _ = require('lodash');
const webpack = require('webpack');
const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
const config = require('../package.json');
const distDir = path.join(__dirname, `../public/dist/${config.name}/${config.version}`);
let baseConfig = require('./webpack.base.config.js');
// cope img fonts
shelljs.mkdir('-p', distDir);
shelljs.cp('-R', path.join(__dirname, '../public/img/'), distDir);
shelljs.cp('-R', path.join(__dirname, '../public/fonts/'), distDir);
baseConfig = baseConfig('pro');
_.mergeWith(baseConfig, {
output: {
path: distDir
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new UglifyJsParallelPlugin({
workers: os.cpus().length,
compress: {
warnings: false
},
comments: false
})
]
}, function customizer(objValue, srcValue) {
if (_.isArray(objValue)) {
return objValue.concat(srcValue);
}
});
module.exports = baseConfig;