Skip to content

Instantly share code, notes, and snippets.

@f0rr0
Last active September 3, 2016 07:03
Show Gist options
  • Save f0rr0/ab81ebb83e2b04509e6dd7f74c5b548d to your computer and use it in GitHub Desktop.
Save f0rr0/ab81ebb83e2b04509e6dd7f74c5b548d to your computer and use it in GitHub Desktop.
HMR
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