Skip to content

Instantly share code, notes, and snippets.

@jmfurlott
Created March 24, 2015 18:23
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 jmfurlott/b06b426df2e0f7affdad to your computer and use it in GitHub Desktop.
Save jmfurlott/b06b426df2e0f7affdad to your computer and use it in GitHub Desktop.
Hot loader issue
/* global process */
/* global __dirname */
'use strict';
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var webpack = require('webpack');
var environment = {
ENV: JSON.stringify(process.env.ENV || "local"),
URI: JSON.stringify(process.env.URI || "http://production.com")
};
/*
* Production Settings
*/
var preLoaders = [];
var app = ['./js/app.js'];
var plugins = [
new ExtractTextPlugin("main.css", {
allChunks: true
}),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin(environment),
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: { warnings: false }
}),
];
/*
* Development Settings
*/
if (JSON.parse(environment.ENV) === "local") {
app = [
// 'webpack-dev-server/client?http://0.0.0.0:8080',
// 'webpack/hot/only-dev-server',
'./js/app.js'
];
preLoaders = [
{
test: /\.js$/, // include .js files
exclude: /node_modules/, // exclude any and all files in the node_modules folder
loader: "jsxhint-loader"
}
];
plugins = [
new ExtractTextPlugin("main.css", {
allChunks: true
}),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin(environment),
];
}
module.exports = {
entry: {
app: app
},
output: {
path: __dirname + '/build',
filename: 'bundle.js'
},
devtool: 'inline-source-map',
module: {
preLoaders: preLoaders,
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader?experimental&optional=selfContained'
},
{
test: /\.js$/,
loaders: ['babel'],
exclude: /node_modules/
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader'
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}, {
test: /\.(png|jpg)$/,
loader: 'url-loader?limit=8192'
}, // inline base64 URLs for <=8k images, direct URLs for the rest
// Font handlers
{
test: /\.woff$/,
loader: "url-loader?limit=10000&minetype=application/font-woff"
},
{
test: /\.ttf$/,
loader: "file-loader"
},
{
test: /\.eot$/,
loader: "file-loader"
},
{
test: /\.svg$/,
loader: "file-loader"
}
]
},
plugins: plugins
};
@jmfurlott
Copy link
Author

Using webpack-dev-server --hot --inline --colors as my watcher/npm start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment