-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
85 lines (80 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
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
80
81
82
83
84
85
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
popup: './src/popup.js',
options: './src/options.js',
analytics: './src/analytics.js',
contentscript: './src/contentscript.js',
background: './src/background.js',
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.css$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract('css-loader?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]!postcss-loader'),
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
exclude: /(node_modules|bower_components)/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml',
},
],
},
plugins: [
new CleanWebpackPlugin(['build']),
new ExtractTextPlugin('[name].css'),
new HtmlWebpackPlugin({
inject: true,
chunks: ['analytics', 'popup'],
chunksSortMode: (chunk1, chunk2) => {
const orders = ['analytics', 'popup'];
const order1 = orders.indexOf(chunk1.names[0]);
const order2 = orders.indexOf(chunk2.names[0]);
if (order1 > order2) {
return 1;
} else if (order1 < order2) {
return -1;
}
return 0;
},
filename: 'popup.html',
template: './src/index.html',
}),
new HtmlWebpackPlugin({
inject: true,
chunks: ['analytics', 'options', 'contentscript'],
chunksSortMode: (chunk1, chunk2) => {
const orders = ['analytics', 'options'];
const order1 = orders.indexOf(chunk1.names[0]);
const order2 = orders.indexOf(chunk2.names[0]);
if (order1 > order2) {
return 1;
} else if (order1 < order2) {
return -1;
}
return 0;
},
filename: 'options.html',
template: './src/index.html',
}),
new CopyWebpackPlugin([
{ context: path.resolve(__dirname), from: 'src/manifest.json' },
{ context: './src/assets', from: '**', to: 'assets' },
]),
],
devtool: 'source-map',
};