text: require('babel-polyfill');
  
  // Webpack config for development
  const fs = require('fs');
  const path = require('path');
  const webpack = require('webpack');
  const webpackIsomorphicTools = require('./webpack-isomorphic-tools');
  // https://github.com/halt-hammerzeit/webpack-isomorphic-tools
  const WebpackIsomorphicToolsPlugin = require('webpack-isomorphic-tools/plugin');
  
  const assetsPath = path.resolve(__dirname, '../static/dist');
  const host = (process.env.HOST || 'localhost');
  const port = (+process.env.PORT + 1) || 3001;
  
  const webpackIsomorphicToolsPlugin = new WebpackIsomorphicToolsPlugin(webpackIsomorphicTools);
  
  const babelrc = fs.readFileSync('./.babelrc');
  let babelrcObject = {};
  
  try {
    babelrcObject = JSON.parse(babelrc);
  } catch (err) {
    /* eslint no-console: ["error", { allow: ["error"] }] */
    console.error('==>     ERROR: Error parsing your .babelrc.');
    console.error(err);
  }
  
  const babelrcObjectDevelopment = (babelrcObject.env && babelrcObject.env.development) || {};
  
  // merge global and dev-only plugins
  let combinedPlugins = babelrcObject.plugins || [];
  combinedPlugins = combinedPlugins.concat(babelrcObjectDevelopment.plugins);
  
  const babelLoaderQuery = Object.assign({}, babelrcObjectDevelopment,
  babelrcObject, { plugins: combinedPlugins });
  babelLoaderQuery.env = null;
  
  // Since we use .babelrc for client and server, and we don't want HMR enabled on
  // the server, we have to add the babel plugin react-transform-hmr manually here.
  
  // make sure react-transform is enabled
  babelLoaderQuery.plugins = babelLoaderQuery.plugins || [];
  let reactTransform = null;
  for (let i = 0; i < babelLoaderQuery.plugins.length; ++i) {
    const plugin = babelLoaderQuery.plugins[i];
    if (Array.isArray(plugin) && plugin[0] === 'react-transform') {
      reactTransform = plugin;
    }
  }
  
  if (!reactTransform) {
    reactTransform = ['react-transform', { transforms: [] }];
    babelLoaderQuery.plugins.push(reactTransform);
  }
  
  if (!reactTransform[1] || !reactTransform[1].transforms) {
    reactTransform[1] = Object.assign({}, reactTransform[1], { transforms: [] });
  }
  
  // make sure react-transform-hmr is enabled
  reactTransform[1].transforms.push({
    transform: 'react-transform-hmr',
    imports: ['react'],
    locals: ['module'],
  });
  
  /* eslint max-len: ["off"] */
  var routeComponentRegex = /(pages|modules\/pageViewModules)\/([^\/]+\/?[^\/]+\/[^\/]+).js$/
  module.exports = {
    devtool: 'source-map',
    context: path.resolve(__dirname, '..'),
  
    entry: {
      main: [
        `webpack-hot-middleware/client?path=http://${host}:${port}/__webpack_hmr`,
        './src/client.js',
      ],
    },
    output: {
      path: assetsPath,
      filename: '[name]-[hash].js',
      chunkFilename: '[name]-[chunkhash].js',
      publicPath: `http://${host}:${port}/dist/`,
    },
    module: {
      loaders: [
        {
          test: /\.jsx?$/,
          exclude: [/node_modules/,routeComponentRegex],
          loaders: [`babel?${JSON.stringify(babelLoaderQuery)}`]
        },
        {
          test: routeComponentRegex,
          loaders: ['bundle?lazy', `babel?${JSON.stringify(babelLoaderQuery)}`]
        },
        // { test: /\.jsx?$/, exclude: /node_modules/, loaders: [`babel?${JSON.stringify(babelLoaderQuery)}`] },
        { test: /\.json$/, loader: 'json-loader' },
        { test: /\.less$/, loader: 'style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap' },
        { test: /\.scss$/, loader: 'style!css?modules&importLoaders=2&sourceMap&localIdentName=[local]___[hash:base64:5]!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap' },
        { test: /\.woff2?(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' },
        { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' },
        { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
        { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' },
        { test: /\.css$/, loader: 'style-loader!css-loader' },
        { test: webpackIsomorphicToolsPlugin.regular_expression('images'), loader: 'url-loader' },
      ],
    },
    progress: true,
    resolve: {
      modulesDirectories: [
        'src',
        'node_modules',
      ],
      extensions: ['', '.json', '.js', '.jsx'],
    },
    plugins: [
      // hot reload
      new webpack.DllReferencePlugin({
       context: '.',
       manifest: require(`${assetsPath}/lib-manifest.json`)
     }),
      new webpack.HotModuleReplacementPlugin(),
      new webpack.IgnorePlugin(/webpack-stats\.json$/),
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: JSON.stringify('development'),
          APP_ENV: JSON.stringify('browser'),
          NODE_FETCH_TOKEN: JSON.stringify('false'),
        },
        __CLIENT__: true,
        __SERVER__: false,
        __DEVELOPMENT__: true,
        __DEVTOOLS__: true,  // <-------- DISABLE redux-devtools HERE
      }),
      // new webpack.optimize.CommonsChunkPlugin({
      //     name:      'common',
      //     children:  true,
      //     minChunks: 2,
      // }),
      webpackIsomorphicToolsPlugin.development(),
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
      }),
    ],
  };
  