react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.87k stars 356 forks source link

Using webpack's ProvidePlugin breaks Hot Module Replacement? #190

Closed gablabelle closed 8 years ago

gablabelle commented 8 years ago

Hello,

I am using the generator-react-webpack and when trying to use webpack's ProvidePlugin I get the following error when the browser launches after doing npm start :

Uncaught Error: [HMR] Hot Module Replacement is disabled. [WDS] Hot Module Replacement enabled.

Hereunder is my cfg/base.js ... If I remove the plugins section it works ok. What am I doing wrong?

'use strict';

let path = require('path');
let webpack = require('webpack');
let port = 8000;
let srcPath = path.join(__dirname, '/../src');
let publicPath = '/assets/';
let additionalPaths = [];

module.exports = {
    plugins: [
        new webpack.ProvidePlugin({
            $: 'jquery',
            _: 'lodash'
        })
    ],
    additionalPaths: additionalPaths,
    port: port,
    debug: true,
    output: {
        path: path.join(__dirname, '/../dist/assets'),
        filename: 'app.js',
        publicPath: publicPath
    },
    devServer: {
        contentBase: './src/',
        historyApiFallback: true,
        hot: true,
        port: port,
        publicPath: publicPath,
        noInfo: false
    },
    resolve: {
        extensions: ['', '.js', '.jsx'],
        alias: {
            actions: srcPath + '/actions/',
            components: srcPath + '/components/',
            sources: srcPath + '/sources/',
            stores: srcPath + '/stores/',
            styles: srcPath + '/styles/',
            config: srcPath + '/config/' + process.env.REACT_WEBPACK_ENV
        }
    },
    module: {
        preLoaders: [{
            test: /\.(js|jsx)$/,
            include: srcPath,
            loader: 'eslint-loader'
        }],
        loaders: [{
            test: /\.css$/,
            loader: 'style-loader!css-loader'
        }, {
            test: /\.sass/,
            loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax'
        }, {
            test: /\.scss/,
            loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded'
        }, {
            test: /\.less/,
            loader: 'style-loader!css-loader!less-loader'
        }, {
            test: /\.styl/,
            loader: 'style-loader!css-loader!stylus-loader'
        }, {
            test: /\.(png|jpg|gif|woff|woff2)$/,
            loader: 'url-loader?limit=8192'
        }]
    }
};
weblogixx commented 8 years ago

Hi @gablabelle,

could you please send me a link to your repo if possible? Will then have a look at it. Thanks.