forked from zalando/zappr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.server.js
44 lines (42 loc) · 1.04 KB
/
webpack.server.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
const path = require('path')
const fs = require('fs')
/**
* Externalize node_modules.
*/
const nodeModules = () => (
fs.readdirSync('node_modules').
filter(x => ['.bin'].indexOf(x) === -1).
reduce((modules, m) => {
modules[m] = 'commonjs2 ' + m
return modules
}, {
'react-dom/server': 'commonjs2 react-dom/server'
})
)
module.exports = {
entry: './server/server.js',
target: 'node',
output: {
libraryTarget: 'commonjs2',
path: path.join(__dirname, 'dist', 'server'),
filename: 'server.min.js'
},
module: {
loaders: [{
test: /\.jsx$/, exclude: /node_modules/, loader: 'babel', query: {
presets: ['es2015-node5', 'stage-1', 'react']
}
}, {
test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: {
presets: ['es2015-node5', 'stage-1']
}
}, {
test: /\.json$/, exclude: /node_modules/, loader: 'json'
}, {
test: /\.png$/, loader: 'url-loader?mimetype=image/png'
}, {
test: /\.svg$/, loader: 'file'
}]
},
externals: nodeModules()
}