Skip to content

Instantly share code, notes, and snippets.

@JaySpears
Created May 8, 2017 16:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JaySpears/5abdc2ed09c0e91cabc726c9a5c3f012 to your computer and use it in GitHub Desktop.
Save JaySpears/5abdc2ed09c0e91cabc726c9a5c3f012 to your computer and use it in GitHub Desktop.
Webpack 2.0 Configuration with React Example
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:3000/',
'webpack/hot/only-dev-server',
path.resolve(__dirname, 'app/index')
],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'build'),
publicPath: '/build/'
},
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.(js|jsx)?$/,
exclude: /(node_modules|bower_components)/,
use: [{
loader: 'babel-loader',
options: {
presets: ['es2015', 'react']
}
}],
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
}
]
},
resolve: {
extensions: ['.js', '.jsx']
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.HotModuleReplacementPlugin()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment