forked from compdemocracy/polis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
48 lines (46 loc) · 2.19 KB
/
webpack.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
// Copyright (C) 2012-present, The Authors. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License, version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
const common = require('./webpack.common');
const path = require('path');
const webpack = require('webpack');
const CompressionPlugin = require('compression-webpack-plugin');
const EventHooksPlugin = require('event-hooks-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const writeHeadersJsonTask = require('./writeHeadersJsonTask');
module.exports = {
...common,
mode: 'production',
output: {
filename: 'report_bundle.[contenthash].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
clean: true,
},
plugins: [
...common.plugins,
new CompressionPlugin({
// It appears that nothing is currently using these gzipped files.
// So we're just going to generate it with the .gz extension and not
// delete the original.
// TODO: Decide if we want to use these gzipped files.
test: /\.js$/,
// filename: '[path][base]',
// deleteOriginalAssets: true,
}),
new EventHooksPlugin({
afterEmit: () => writeHeadersJsonTask(),
}),
new MiniCssExtractPlugin({
filename: 'report_style.[contenthash].css',
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.SERVICE_URL': null,
})
],
performance: {
// TODO: Find and remove orphan modules; Reduce bundle size.
hints: 'warning', // 'error' for errors, 'warning' for warnings, false to disable
maxAssetSize: 505000, // Size limit in bytes, default is 250000 (250 KB)
maxEntrypointSize: 500000, // Size limit in bytes, default is 250000 (250 KB)
},
};