Skip to content

Instantly share code, notes, and snippets.

@dburles
Created November 13, 2016 04:26
Show Gist options
  • Select an option

  • Save dburles/c22b6437e58ec4e4f5cf62a8e03e4d89 to your computer and use it in GitHub Desktop.

Select an option

Save dburles/c22b6437e58ec4e4f5cf62a8e03e4d89 to your computer and use it in GitHub Desktop.
// Backend config example
// http://jlongster.com/Backend-Apps-with-Webpack--Part-I
var path = require('path');
var webpack = require('webpack');
var fs = require('fs');
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
module.exports = {
target: 'node',
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: ['es2015']
}
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
externals: nodeModules
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment