-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.server.config.js
70 lines (56 loc) · 1.16 KB
/
webpack.server.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
65
66
67
68
69
70
const path = require("path")
const fs = require("fs")
// -- Webpack configuration --
const config = {}
// Application entry point
config.entry = "./src/server/index.js"
// We build for node
config.target = "node"
// Node module dependencies should not be bundled
config.externals = fs.readdirSync("node_modules")
.reduce(function(acc, mod) {
if (mod === ".bin") {
return acc
}
acc[mod] = "commonjs " + mod
return acc
}, {})
// We are outputting a real node app!
config.node = {
console: false,
global: false,
process: false,
Buffer: false,
__filename: false,
__dirname: false,
}
// Output files in the build/ folder
config.output = {
path: path.join(__dirname, "build"),
filename: "[name].js",
}
config.resolve = {
extensions: [
"",
".js",
".json",
],
}
config.module = {}
config.module.loaders = [
// Use babel and eslint to build and validate JavaScript
{
test: /\.js$/,
exclude: /node_modules/,
loaders: [
"babel?{stage:0,jsxPragma:'this.createElement'}",
"eslint",
],
},
// Allow loading of JSON files
{
test: /\.json$/,
loader: "json",
},
]
module.exports = config