'use strict';

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

module.exports = {
	watch: true,
	mode: "development",
	entry: {
		main: [
			"webpack-hot-middleware/client?overlay=true&reload=true",
			"./frontend/index.jsx"
		]
	},
	output: {
		publicPath: "/",
		path: path.join(__dirname, "public/static/"),
		filename: "bundle.js"
	},
	module: {
		rules: [{
			test: /\.jsx?$/,
			exclude: /node_modules|src\/testcases/,
			resolve: {
				extensions: [".js", ".jsx"]
			},
			use: [{
				loader: require.resolve("babel-loader"),
				query: {
					presets: [
						"es2015",
						"react"
					].map(item => require.resolve(`babel-preset-${item}`))
				}
			}]
		}]
	},
	plugins: [
		new webpack.HotModuleReplacementPlugin(),
		new webpack.NoEmitOnErrorsPlugin()
	],
	devtool: "source-map"
};
