config/webpack.dev.config.js
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable global-require */
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
index: [
'webpack-hot-middleware/client',
'./client/index.jsx',
],
admin: [
'webpack-hot-middleware/client',
'./client/admin.jsx',
],
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.jsx$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.css$/,
loader: 'style-loader!css-loader?sourceMap',
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
},
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=application/octet-stream',
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000&mimetype=image/svg+xml',
},
{
test: /\.(jpe?g|gif|png)$/,
loader: 'file-loader',
},
{
test: /\.js$/,
loader: 'source-map-loader',
enforce: 'pre',
},
],
},
resolve: {
extensions: ['.js', '.jsx'],
},
output: {
path: path.resolve(__dirname, '..', 'dist'),
filename: '[name]/bundle.js',
publicPath: '/',
},
plugins: [
new HtmlWebpackPlugin({
template: './client/index.html',
filename: 'index.html',
inject: 'body',
chunks: ['index'],
hash: true,
}),
new HtmlWebpackPlugin({
template: './client/admin.html',
filename: 'admin.html',
inject: 'body',
chunks: ['admin'],
hash: true,
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
],
devServer: {
historyApiFallback: true,
},
};