-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
79 lines (71 loc) · 1.79 KB
/
webpack.config.js
File metadata and controls
79 lines (71 loc) · 1.79 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const path = require('path');
let package = require('./package.json');
function modify(buffer) {
// copy-webpack-plugin passes a buffer
var manifest = JSON.parse(buffer.toString());
// make any modifications you like, such as
manifest.version = package.version;
// pretty print to JSON with two spaces
manifest_JSON = JSON.stringify(manifest, null, 2);
return manifest_JSON;
}
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const pages = ['popup', 'lazyloading', 'options']
const entries = ['popup', 'background', 'lazyloading', 'options']
module.exports = {
entry: entries.reduce((config, entry) => {
config[entry] = `./${entry}.js`;
return config;
}, {}),
plugins: [].concat(
pages.map(
(page) =>
new HtmlWebpackPlugin({
inject: false,
template: `./${page}.html`,
filename: `${page}.html`,
chunks: [page],
})
),
[
new CopyPlugin({
patterns: [
{
from: "./manifest.json",
to: "./",
transform (content, path) {
return modify(content)
}
},
{
from: "./images/urlqa128.png",
to: "./images/",
}
],
}),
new MiniCssExtractPlugin(),
]
),
optimization: {
minimizer: [
`...`,
new CssMinimizerPlugin(),
],
},
module: {
rules: [
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
clean: true
},
};