Skip to content

Instantly share code, notes, and snippets.

@Piterden
Forked from ramsaylanier/webpack.config.js
Created June 18, 2016 18:50
Show Gist options
  • Save Piterden/f5e265a813306966510c5bf367d6ca85 to your computer and use it in GitHub Desktop.
Save Piterden/f5e265a813306966510c5bf367d6ca85 to your computer and use it in GitHub Desktop.
'use strict';
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var WriteFilePlugin = require('write-file-webpack-plugin');
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const devServer = {
contentBase: path.resolve(__dirname, './app'),
outputPath: path.join(__dirname, './dist'),
colors: true,
quiet: false,
noInfo: false,
publicPath: '/',
historyApiFallback: false,
host: '127.0.0.1',
proxy:{
'/graphql': {
target: 'http://localhost:8080'
}
},
port: 3000,
hot: true
};
module.exports = {
devtool: 'eval-source-map',
debug: true,
devServer: devServer,
entry: [
'webpack/hot/dev-server',
'webpack-hot-middleware/client?reload=true',
path.join(__dirname, 'app/main.js')
],
output: {
path: path.join(__dirname, '/dist/'),
filename: '[name].js',
publicPath: devServer.publicPath
},
module: {
loaders: [
{
test: /\.js?$/,
loader: 'babel',
exclude: /node_modules|lib/,
},
{
test: /\.json?$/,
loader: 'json'
},
{
test: /\.css$/,
loader: 'style!css?modules&localIdentName=[name]---[local]---[hash:base64:5]'
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[name]__[local]!sass'),
exclude: /node_modules|lib/,
},
],
},
plugins: [
new WriteFilePlugin(),
new ExtractTextPlugin('app.css', {
allChunks: true
}),
new HtmlWebpackPlugin({
template: 'app/index.tpl.html',
inject: 'body',
filename: 'index.html'
}),
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
proxy: 'http://localhost:3100/'
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('dev')
})
],
node: {
fs: 'empty'
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment