title: Webpack babel config for both server and client javascript?
body: <p>I'm trying to figure out how to have a single webpack config file that works for transforming both server (node.js) js and client js with the es2015 preset. Currently I have to specifically set "target: 'node'" for it to correctly process node-based files. If I don't, then webpack does the transformation based on the default "target: 'web'". It then reports errors because the 'mysql' module being imported clearly won't work for web.</p>
  
  <p>How can I unify both into the same config file so that server and client js will be transformed separately? Or do I need separate configs entirely?</p>
  
  <p>Sample webpack.config.js</p>
  
  <pre><code>'use strict';
  
  var path = require('path');
  var webpack = require('webpack');
  
  module.exports = {
    target: 'node',
    resolve: {
      root: path.resolve(__dirname),
      extensions: ['', '.js']
    },
    entry: [
      'babel-polyfill',
      './index.js',
    ],
    output: {
      filename: 'bundle.js'       
    },
    module: {
      loaders: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'babel',
          query: {
            presets: ['es2015']
          }
        }
      ]
    }
  };
  </code></pre>
  
  <p>Sample js code</p>
  
  <pre><code>import 'babel-polyfill';
  import mysql from 'mysql';
  
  class Test {
    constructor () {
  
    }
  
    get read () {
  
    }
  };
  </code></pre>