-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
56 lines (54 loc) · 1.86 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
/* eslint-env node */
const path = require('path')
const webpack = require('webpack')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
module.exports = function ({production}) {
// TODO[setup]: Create a separate package with normal package.json
// dependencies installed in node_modules
// For example restore the normal separation between 'dependencies' and
// 'devDependencies' in package.json, but, when building the
// compiled/bundled version, temporarily merge 'dependencies' into
// 'devDependencies'
// TODO[setup]: Use an equivalent to licensify, especially with the bundled
// version
return {
entry: {
index: path.resolve(__dirname, 'src', 'index.js'),
'report-todo': path.resolve(__dirname, 'aux', 'report-todo.js'),
},
target: 'node',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
library: 'report-todo',
libraryTarget: 'umd',
},
// Defining 'externals' prevents the 'report-todo' library from being
// bundled directly also with the report-todo.js script
externals: {
'report-todo': 'commonjs2 report-todo',
},
// 'mode' also sets NODE_ENV through DefinePlugin
mode: production ? 'production' : 'development',
// TODO[setup]: Use a proper devtool in production
// https://webpack.js.org/configuration/devtool/#production
devtool: production ? false : 'eval-source-map',
resolve: {
alias: {
// Keep in sync with Jest's moduleNameMapper
},
},
plugins: [
new CleanWebpackPlugin(),
new webpack.DefinePlugin({
// NODE_ENV is automatically set by 'mode', however DefinePlugin must be
// instantiated here
}),
new webpack.BannerPlugin({
banner: '#!/usr/bin/env node\n',
raw: true,
include: 'report-todo.js',
}),
],
}
}