var fs = require('fs')
var path = require('path')

module.exports = {
  entry: path.resolve(__dirname, 'server.js'),
  output: {
    filename: 'build/server.js'
  },
  target: 'node',
  externals: fs.readdirSync(path.resolve(__dirname, '../node_modules')).reduce((ext, mod) => {
    ext[mod] = 'commonjs ' + mod
    return ext
  }, {}),
  node: {
    __filename: true,
    __dirname: true
  },
  module: {
    loaders: [
      { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=es2017' }
    ]
  }
}
