Skip to content

Instantly share code, notes, and snippets.

@moizhb
Created January 17, 2017 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moizhb/f873289671ec5277b9405d7f90fe0873 to your computer and use it in GitHub Desktop.
Save moizhb/f873289671ec5277b9405d7f90fe0873 to your computer and use it in GitHub Desktop.
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: [
'eventsource-polyfill', // necessary for hot reloading with IE
'webpack-hot-middleware/client',
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle-[hash].js',
publicPath: '/'
},
plugins: [
/**
* This is where the magic happens! You need this to enable Hot Module Replacement!
*/
new webpack.HotModuleReplacementPlugin(),
/**
* NoErrorsPlugin prevents your webpack CLI from exiting with an error code if
* there are errors during compiling - essentially, assets that include errors
* will not be emitted. If you want your webpack to 'fail', you need to check out
* the bail option.
*/
new webpack.NoErrorsPlugin(),
/**
* This is a webpack plugin that simplifies creation of HTML files to serve your
* webpack bundles. This is especially useful for webpack bundles that
* include a hash in the filename which changes every compilation.
*/
new HtmlWebpackPlugin({
template: 'index.html',
title: 'Simple Redux Boilerplate',
inject: 'body'
}),
/**
* DefinePlugin allows us to define free variables, in any webpack build, you can
* use it to create separate builds with debug logging or adding global constants!
* Here, we use it to specify a development build.
*/
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
}),
],
module: {
loaders: [
{
test: /\.js?/,
exclude: [/node_modules/, /styles/],
loaders: ['babel'],
include: path.join(__dirname, 'src')
},
{
test: /\.scss$/,
loader: 'style!css!sass?outputStyle=compressed'
}
]
},
sassLoader: {
includePaths: [
'./node_modules'
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment