-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack-node.config.js
47 lines (37 loc) · 1.01 KB
/
webpack-node.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
var webpack = require('webpack')
var fs = require('fs')
var path = require('path')
module.exports = {
target: 'node',
devtool: 'inline-source-map',
entry: { node: ['./service/App.js'] },
output: {
chunkFilename: './nodebundle/[name].js',
filename: './nodebundle/[name].bundle.js',
},
// keep node_module paths out of the bundle keep size down
externals: getExternals(),
node: {
__filename: true,
__dirname: true
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
}
]
},
plugins: [
new webpack.BannerPlugin('require("source-map-support").install();', { raw: true, entryOnly: false })
]
}
function getExternals() {
const nodeModules = fs.readdirSync(path.resolve(__dirname, 'node_modules'))
return nodeModules.reduce((ext, mod) => {
ext[mod] = 'commonjs ' + mod
return ext
}, {})
}