-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
40 lines (39 loc) · 1.14 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
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env) => {
const shortEnv = env.production ? 'prod' : 'dev';
return {
entry: {
content: ['./src/content'],
background: ['./src/background'],
options: ['./src/options'],
popup: ['./src/popup'],
},
plugins: [
new CleanWebpackPlugin(['dist']),
new CopyWebpackPlugin([
{ from: `src/manifest.${shortEnv}.json`, to: 'manifest.json' },
{ from: 'icons', to: 'icons' },
{ from: 'src/options/index.html', to: 'options.html' },
{ from: 'src/popup/index.html', to: 'popup.html' },
{ from: 'src/scripts', to: 'scripts' },
]),
],
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
devtool: env.production ? false : 'cheap-source-map',
mode: env.production ? 'production' : 'development',
};
};