forked from chinchang/web-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreact.config.js
More file actions
43 lines (38 loc) · 1.26 KB
/
preact.config.js
File metadata and controls
43 lines (38 loc) · 1.26 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
import CopyWebpackPlugin from 'copy-webpack-plugin';
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
/**
* Function that mutates original webpack config.
* Supports asynchronous changes when promise is returned.
*
* @param {object} config - original webpack config.
* @param {object} env - options passed to CLI.
* @param {WebpackConfigHelpers} helpers - object with useful helpers when working with config.
**/
export default function(config, env, helpers) {
const htmlWebpackPlugin = helpers.getPluginsByName(
config,
'HtmlWebpackPlugin'
)[0];
Object.assign(htmlWebpackPlugin.plugin.options.minify, {
removeComments: false,
collapseWhitespace: false
});
htmlWebpackPlugin.plugin.options.preload = false;
htmlWebpackPlugin.plugin.options.favicon = false;
if (env.isProd) {
config.devtool = false; // disable sourcemaps
config.plugins.push(
new CommonsChunkPlugin({
name: 'vendor',
minChunks: ({ resource }) => /node_modules/.test(resource)
})
);
const swPlugin = helpers.getPluginsByName(
config,
'SWPrecacheWebpackPlugin'
)[0];
config.plugins.splice(swPlugin.index, 1);
const uglifyPlugin = helpers.getPluginsByName(config, 'UglifyJsPlugin')[0];
config.plugins.splice(uglifyPlugin.index, 1);
}
}