-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
54 lines (48 loc) · 1.3 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
var path = require('path');
var webpack = require('webpack');
var packageJson = require('./package.json');
var release = process.env.NODE_ENV === 'production';
var plugins = [
// Optional binary requires that should be ignored
new webpack.IgnorePlugin({
resourceRegExp: /.*\/build\/.*\/(validation|bufferutil)/
}),
new webpack.DefinePlugin({
'EXTENSION_NAME': JSON.stringify(packageJson.name),
'EXTENSION_VERSION': JSON.stringify(packageJson.version),
'EXTENSION_BUILD_TIME': JSON.stringify((new Date).getTime()),
})
];
console.log('Release: ' + release);
if (!release) {
// Required for debugging
// Release build should add the require manually so that the module gets bundled
plugins.push(
new webpack.BannerPlugin({
banner: 'require("source-map-support").install();',
raw: true,
entryOnly: false
})
);
}
module.exports = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry: release ? './src/index.js' : './src/main.js',
target: 'node',
output: {
path: path.join(__dirname, 'dist'),
filename: 'main.js',
libraryTarget: 'umd'
},
plugins: plugins,
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js)$/,
include: /src/,
use: 'babel-loader',
}
]
},
}