forked from mozilla/web-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
76 lines (70 loc) · 1.75 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
/*eslint prefer-template: 0*/
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
var nodeModules = {};
// This is to filter out node_modules as we don't want them
// to be made part of any bundles.
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
var rules = [
{
exclude: /(node_modules|bower_components)/,
test: /\.js$/,
// babel options are in .babelrc
loaders: ['babel-loader'],
},
];
if (process.env.COVERAGE === 'y') {
rules.push({
test: /\.js$/,
enforce: 'pre',
exclude: /(node_modules|bower_components|test)/,
loaders: 'babel-istanbul-loader',
});
}
module.exports = {
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: nodeModules,
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',
};