forked from mozilla/web-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
66 lines (63 loc) · 1.7 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
/*eslint prefer-template: 0*/
var path = require('path');
var webpack = require('webpack');
// Do not bundle any external module, because those are explicitly added as
// "dependencies" in package.json. Bundling them anyway could result in bugs
// like https://github.com/mozilla/web-ext/issues/1629
var nodeExternals = require('webpack-node-externals');
var rules = [
{
exclude: /(node_modules|bower_components)/,
test: /\.js$/,
// babel options are in .babelrc
loaders: ['babel-loader'],
},
];
module.exports = {
mode: process.env.NODE_ENV && process.env.NODE_ENV !== 'test' ?
process.env.NODE_ENV : 'development',
entry: './src/main.js',
target: 'node',
node: {
__dirname: true,
__filename: true,
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'web-ext.js',
libraryTarget: 'commonjs2',
},
module: {
rules,
},
externals: [
nodeExternals({
modulesFromFile: {
include: ['dependencies'],
},
}),
],
plugins: [
new webpack.BannerPlugin({
banner: 'require("source-map-support").install();',
raw: true,
entryOnly: false,
}),
// This seems necessary to work with the 'when' module, which is
// required by some things such as fx-runner.
new webpack.IgnorePlugin(/vertx/),
// Global variables are necessary to print either verson number or
// git commit information for custom builds
new webpack.DefinePlugin({
WEBEXT_BUILD_ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
}),
],
resolve: {
extensions: ['.js', '.json'],
modules: [
path.join(__dirname, 'src'),
path.resolve(__dirname, 'node_modules'),
],
},
devtool: 'sourcemap',
};