-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
71 lines (69 loc) · 1.95 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
'use strict';
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
// Each entry in here would declare a file that needs to be transpiled
// and included in the extension source.
// For example, you could add a background script like:
background: './src/background.js',
content: './src/content.js',
options: './src/options.js',
},
output: {
// This copies each source entry into the extension dist folder named
// after its entry config key.
path: path.join(path.resolve(__dirname), 'ext', 'dist'),
filename: '[name].js',
},
module: {
// This transpiles all code (except for third party modules) using Babel.
rules: [{
exclude: /node_modules/,
test: /\.js$/,
// Babel options are in .babelrc
use: 'babel-loader',
}],
},
resolve: {
// This allows you to import modules just like you would in a NodeJS app.
extensions: ['.js', '.jsx'],
modules: [
'src',
'node_modules',
],
},
plugins: [
new CopyWebpackPlugin([
{
from: '*',
context: 'src',
ignore: '*.js'
},
{
from: 'node_modules/webextension-polyfill/dist/browser-polyfill.min.js'
}
]),
],
optimization: {
// Without this, function names will be garbled and enableFeature won't work
concatenateModules: true,
// Automatically enabled on prod; keeps it somewhat readable for AMO reviewers
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
mangle: false,
compress: false,
output: {
beautify: true,
indent_level: 2 // eslint-disable-line camelcase
}
}
})
]
},
// This will expose source map files so that errors will point to your
// original source files instead of the transpiled files.
devtool: 'sourcemap',
};