forked from signum-network/signum-xt-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.html.config.js
48 lines (44 loc) · 1.24 KB
/
webpack.html.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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const htmlPluginOptions =
process.env.NODE_ENV === 'production'
? {
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
}
: {};
const getTemplateEntry = (publicPath, name) => ({
path: path.join(publicPath, `${name}.html`),
chunks: [name]
});
module.exports = publicPath => {
const htmlTemplates = [
getTemplateEntry(publicPath, 'popup'),
getTemplateEntry(publicPath, 'fullpage'),
getTemplateEntry(publicPath, 'confirm'),
getTemplateEntry(publicPath, 'options')
];
return htmlTemplates.map(
htmlTemplate =>
new HtmlWebpackPlugin({
template: htmlTemplate.path,
filename: path.basename(htmlTemplate.path),
chunks: [...htmlTemplate.chunks, 'commons'],
inject: 'body',
templateParameters: {
process
},
...htmlPluginOptions
})
);
};