/
webpack.config.prod.js
53 lines (46 loc) · 1.46 KB
/
webpack.config.prod.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
'use strict';
const path = require('path');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const paths = require('./paths');
const Typeof = require('../utils/typeof');
let config = require('./webpack.config.base');
if (Typeof.isUndefined(config.output.filename)) {
config.output.filename = '[name].[chunkhash:8].js';
}
if (Typeof.isUndefined(config.output.chunkFilename)) {
config.output.chunkFilename = '[name].chunk.[chunkhash:8].js';
}
config.output.pathinfo = false;
config.devtool = false;
config.plugins.push(
new HardSourceWebpackPlugin({
cacheDirectory: path.join(
paths.appCache,
'hard-source',
'[confighash]'
),
// Either a string of object hash function given a webpack config.
configHash: function(webpackConfig) {
// node-object-hash on npm can be used to build this.
return require('node-object-hash')({ sort: false }).hash(
webpackConfig
);
},
// Clean up large, old caches automatically.
cachePrune: {
// Caches younger than `maxAge` are not considered for deletion. They must
// be at least this (default: 2 days) old in milliseconds.
maxAge: 2 * 24 * 60 * 60 * 1000,
// All caches together must be larger than `sizeThreshold` before any
// caches will be deleted. Together they must be at least this
// (default: 50 MB) big in bytes.
sizeThreshold: 50 * 1024 * 1024,
},
info: {
mode: 'none',
level: 'error',
},
})
);
config.mode = 'production';
module.exports = config;