Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack hot reload doesnt work #741

Closed
stallter4 opened this issue Jan 14, 2017 · 2 comments
Closed

webpack hot reload doesnt work #741

stallter4 opened this issue Jan 14, 2017 · 2 comments

Comments

@stallter4
Copy link

I am using webpack 1.14.0 I just downloaded a month ago.

I am trying to use webpack-dev-server --content-base /output --inline --hot

First of all if I serve it from this content base I get the file structure appearing in the browser and not the output from the webpack build. Secondly, the hot swap does not work at all. Sometimes it will show that it has built something in the command prompt but it doesnt refresh or upon refreshing does not show changes. The documentation and instructions for this part of webpack are severly lacking and the internet is cluttered with this issue.

Here's the main part of my webpack.config:

var DEV = path.resolve(__dirname, "dev");
var OUTPUT = path.resolve(__dirname, "output");

var config = {
    entry: [DEV + "/index.jsx"],
    output: {
        path: OUTPUT,
        filename: "app.js"
    },
    plugins: [
        new ExtractTextPlugin('styles.css'),
       /* new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify('production')
            }
        }),
        new webpack.optimize.UglifyJsPlugin()*/
    ],
    module: {
        loaders: [
            {
                test: /\.js/,
                include: DEV,
                loaders: ["react-hot", "babel-loader"],
            },
            {
                test: /\.css$/,
                loader: 'style-loader'
            }, {
                test: /\.css$/,
                loader: 'css-loader',
                query: {
                    modules: true,
                    localIdentName: '[name]__[local]___[hash:base64:5]'
                }
            }
        ],
    }
};
@stallter4
Copy link
Author

I figured out my problem after about 4 hours of fiddling. It is never stated anywhere that the index.html and the output of the webpack build should be in the same folder, or that index.html can not be on the very outtermost part of the file structure. However, if you do this the content-base does not work right, and therefore the hot swap doesnt work. I figured it out by following this guys tutorial and making sure my stuff looked like his:

http://andrewhfarmer.com/webpack-hmr-tutorial/

@rfgamaral
Copy link

@stallter4 How exactly did you get HMR working? I looked through the link you posted but couldn't fix it on my end... I created a new issue (#742) because it might be a little different. Could you perhaps take a look and see if I'm making the same mistake as you? What exactly did you change on your end?

@bebraw bebraw closed this as completed Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants