-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
64 lines (58 loc) · 1.58 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
const path = require('path');
const webpack = require('webpack');
const packageJson = require('./package.json');
const release = process.env.NODE_ENV === 'production';
const profiling = !!process.env.PROFILING;
const plugins = [
// Optional binary requires that should be ignored
new webpack.IgnorePlugin(/.*\/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);
console.log('Profiling: ' + profiling);
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 && !profiling ? './src/index.ts' : './src/main.ts',
target: 'node',
output: {
path: path.join(__dirname, 'dist'),
filename: 'main.js',
libraryTarget: 'umd'
},
optimization: {
minimize: release && !profiling ? true : false,
},
plugins: plugins,
devtool: 'source-map',
module: {
rules: [
{
test: /\.(ts|js)$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
resolve: {
extensions: [ '.ts', '.js' ],
modules: [
path.resolve('./src'),
'node_modules'
],
},
}