Skip to content

Instantly share code, notes, and snippets.

@willopez
Last active December 11, 2015 04:23
Show Gist options
  • Save willopez/4f3d6a9840383ab7731a to your computer and use it in GitHub Desktop.
Save willopez/4f3d6a9840383ab7731a to your computer and use it in GitHub Desktop.
webpack config
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var config = require('./config');
var NoErrorsPlugin = webpack.NoErrorsPlugin;
var optimize = webpack.optimize;
var webpackConfig = module.exports = {
entry: {
auth: ['./src/client/auth.js']
},
output: {
path: './public/js',
filename: '[name].js',
publicPath: 'http://localhost:' + config.devPort + '/js/'
},
resolve: {
extensions: ['', '.js', '.jsx', '.json']
},
plugins: [
new optimize.OccurenceOrderPlugin(),
new optimize.CommonsChunkPlugin('common.js', ['admin', 'auth', 'public'])
],
module: {
loaders: [
{
test: /\.(js|jsx)$/,
loader: 'babel',
query: {
optional: ['runtime'],
env: {
development: {
plugins: [
'react-transform'
],
extra: {
'react-transform': {
transforms: [{
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
}, {
transform: 'react-transform-catch-errors',
imports: ['react', 'redbox-react']
}]
}
}
}
}
},
exclude: /node_modules/
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(woff|woff2|ttf|eot|svg|png|jpg|jpeg|gif)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url'
}
]
},
devServer: {
port: config.devPort,
contentBase: 'http://localhost:' + config.port
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment