-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.server.config.js
More file actions
53 lines (50 loc) · 1.17 KB
/
webpack.server.config.js
File metadata and controls
53 lines (50 loc) · 1.17 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
/* eslint-disable import/no-extraneous-dependencies */
const webpack = require("webpack");
/* eslint-enable */
const _ = require("lodash");
const path = require("path");
const fs = require("fs");
const IS_PROD = process.env.NODE_ENV === "production";
const nodeModules = {};
fs.readdirSync("node_modules")
.filter(x => [".bin"].indexOf(x) === -1)
.forEach((mod) => {
nodeModules[mod] = `commonjs ${mod}`;
});
module.exports = {
entry: _.filter([
IS_PROD ? null : "webpack/hot/poll?1000",
"babel-polyfill",
"./server.js",
]),
target: "node",
node: {
__dirname: true,
__filename: true,
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "server.bundle.js",
},
module: {
rules: [
{
test: /\.js$/,
loader: "babel-loader",
query: {
presets: ["env", "stage-0"],
},
},
],
},
plugins: _.filter([
new webpack.BannerPlugin({
banner: "require('source-map-support').install();",
raw: true,
entryOnly: false,
}),
new webpack.NamedModulesPlugin(),
IS_PROD ? null : new webpack.HotModuleReplacementPlugin(),
]),
externals: nodeModules,
};