Last active
September 3, 2016 07:03
-
-
Save f0rr0/ab81ebb83e2b04509e6dd7f74c5b548d to your computer and use it in GitHub Desktop.
HMR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { resolve } = require('path'); | |
const { dependencies } = require('./package.json'); | |
const BabiliPlugin = require("babili-webpack-plugin"); | |
const nodeModules = {}; | |
Object | |
.keys(dependencies) | |
.forEach((mod) => { | |
nodeModules[mod] = `commonjs ${mod}`; | |
}); | |
module.exports = (env = { dev: true }) => ({ | |
context: resolve(__dirname, './src'), | |
entry: { | |
server: env.prod ? './index.js' : ['webpack/hot/poll?1000', './index.js'] | |
}, | |
target: 'node', | |
output: { | |
filename: '[name].js', | |
path: resolve(__dirname, './build'), | |
pathInfo: !env.prod | |
}, | |
devtool: env.prod ? 'source-map' : 'eval', | |
module: { | |
loaders: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
loaders: [ | |
'babel-loader' | |
] | |
} | |
] | |
}, | |
plugins: env.prod ? [ | |
new BabiliPlugin() | |
] : [], | |
externals: nodeModules | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment