Skip to content

Instantly share code, notes, and snippets.

@duhduhdan
Created May 5, 2016 14:22
Show Gist options
  • Save duhduhdan/776ed9c595e0561f539a58607e8e64c0 to your computer and use it in GitHub Desktop.
Save duhduhdan/776ed9c595e0561f539a58607e8e64c0 to your computer and use it in GitHub Desktop.
Basic Webpack Setup
const path = require('path')
const webpack = require('webpack')
const root = path.normalize(__dirname, '/client')
const dist = path.join(root, '/dist')
const appEntry = path.join(root, '/src/client.js')
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
appEntry,
],
module: {
preLoaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'eslint' },
],
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'react-hot' },
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
{ test: /\.scss$/, loaders: ['style', 'css', 'sass', 'autoprefixer'] },
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&progressive',
],
},
],
},
resolve: {
extensions: ['', '.js'],
},
output: {
path: dist,
filename: 'bundle.js',
chunkFilename: '[id].chunk.js',
publicPath: '/',
},
devServer: {
contentBase: dist,
hot: true,
colors: true,
port: 8080,
host: '0.0.0.0',
inline: true,
},
plugins: [
new webpack.optimize.CommonsChunkPlugin('shared.js'),
new webpack.HotModuleReplacementPlugin(),
],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment