/* eslint import/no-extraneous-dependencies: "warn" */

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: {
    app: [
      'react-hot-loader/patch',
      'webpack-dev-server/client?http://localhost:5001/',
      'webpack/hot/only-dev-server',
      './src/client/index.js',
    ],
  },
  output: {
    path: `${__dirname}/../public/`,
    publicPath: '/public/',
    pathinfo: true,
    filename: 'bundle.js',
  },
  context: path.resolve(__dirname, '..'),
  devtool: 'inline-source-map',
  devServer: {
    hot: true,
    // enable HMR on the server

    contentBase: path.resolve(__dirname, '..', 'public'),
    // match the output path

    publicPath: '/public/',
    // match the output `publicPath`
  },
  module: {
    rules: [
      {
        test: /(\.js|\.jsx)$/,
        exclude: /(node_modules)/,
        use: 'babel-loader',
      },
    ],
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify('development'),
    }),

    // enable HMR globally
    new webpack.HotModuleReplacementPlugin()
  ],
};
