text: /* @flow */
  
  const resolvePath = path => require('path').resolve(__dirname, path)
  
  const webpack = require('webpack')
  
  const webpackServerConfig = {
    devtool: 'source-map',
    entry: resolvePath(
      '../../source/server/entry/serverSideRender.entry.production.js',
    ),
    mode: 'production',
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'babel-loader',
          options: {
            plugins: [
              'babel-plugin-universal-import',
              ['babel-plugin-styled-components', { ssr: true }],
            ],
            presets: [['env', { modules: false }], 'flow', 'react', 'stage-0'],
          },
        },
        {
          test: /\.(gif|ico|jpg|png|svg)$/,
          loader: 'url-loader',
        },
      ],
    },
    name: 'server',
    output: {
      filename: 'serverSideRender.js',
      libraryTarget: 'commonjs2',
      path: resolvePath('../../server/production'),
    },
    plugins: [
      new webpack.optimize.LimitChunkCountPlugin({
        maxChunks: 1,
      }),
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: JSON.stringify('production'),
          REACT_CONTAINER_ID: JSON.stringify('react-container'),
        },
      }),
    ],
    resolve: {
      extensions: ['.js'],
      modules: [resolvePath('../../source'), 'node_modules'],
    },
    target: 'node',
  }
  
  module.exports = webpackServerConfig
  