-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
executable file
·59 lines (56 loc) · 1.61 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
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const FlowWebpackPlugin = require('flow-webpack-plugin');
const fileExtensions = ['jpg', 'jpeg', 'png', 'gif', 'eot', 'otf', 'svg', 'ttf', 'woff', 'woff2'];
const options = {
entry: {
options: path.join(__dirname, 'src', 'js', 'options.js'),
overlay: path.join(__dirname, 'src', 'js', 'overlay.js'),
background: path.join(__dirname, 'src', 'js', 'background.js'),
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: 'remove-flow-types-loader',
},
{
test: /\.css$/,
loader: 'style-loader!css-loader',
exclude: /node_modules/,
},
{
test: new RegExp(`\.(${fileExtensions.join('|')})$`),
loader: 'file-loader?name=[name].[ext]',
exclude: /node_modules/,
},
{
test: /\.html$/,
loader: 'file-loader?name=[name].[ext]!extract-loader!html-loader',
},
],
},
resolve: {},
plugins: [
new CleanWebpackPlugin(['dist']),
new CopyWebpackPlugin([{
from: 'src/manifest.json',
transform: (content) => (
Buffer.from(JSON.stringify({
name: process.env.npm_package_name,
description: process.env.npm_package_description,
version: process.env.npm_package_version,
...JSON.parse(content.toString()),
}))
),
}]),
new FlowWebpackPlugin(),
],
};
module.exports = options;