-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (57 loc) · 1.47 KB
/
webpack.config.js
File metadata and controls
61 lines (57 loc) · 1.47 KB
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
// Webpack config adopted from `backpack` project,
// https://github.com/jaredpalmer/backpack/blob/6b448c43831e1afa40962aa24c81c2b209134ef3/packages/backpack-core/config/webpack.config.js
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const PATHS = {
src: path.resolve(__dirname, 'src'),
build: path.resolve(__dirname, 'build'),
};
module.exports = () => {
return {
// NOTE: Using production mode includes `UglifyJsPlugin`, which breaks async functions.
mode: 'none',
target: 'node',
// exclude node_modules from bundling, except for asset resources
externals: nodeExternals({
whitelist: [
/\.(eot|woff|woff2|ttf|otf)$/,
/\.(svg|png|jpg|jpeg|gif|ico|webm)$/,
/\.(mp4|mp3|ogg|swf|webp)$/,
/\.(css|scss|sass|less|styl)$/,
],
}),
// ignore bundle size perf hints
performance: {
hints: false,
},
node: {
__filename: true,
__dirname: true,
},
entry: {
server: [
path.join( PATHS.src, 'server.js' ),
],
},
output: {
path: PATHS.build,
filename: '[name].js',
sourceMapFilename: '[name].map',
libraryTarget: 'commonjs2',
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: PATHS.src,
options: {
babelrc: true,
cacheDirectory: true,
},
},
],
},
plugins: [],
};
};