question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't get hot reload to work with my setup...

See original GitHub issue

I’m using the following webpack and webpack-dev-server versions:

"webpack": "^2.2.0-rc.7",
"webpack-dev-server": "^2.2.0-rc.0"

And this is my webpack.config.js file:

var path = require('path');

var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        app: path.join(__dirname, 'app', 'src', 'Index.tsx')
    },

    output: {
        path: path.join(__dirname, 'build'),
        filename: '[name].[hash:8].js'
    },

    devtool: 'source-map',

    resolve: {
        extensions: ['.ts', '.tsx', '.js']
    },

    module: {
        rules: [
            {
                include: path.join(__dirname, 'app'),
                loader: 'awesome-typescript-loader',
                test: /\.tsx?$/,
            },
            {
                include: path.join(__dirname, 'app'),
                loader: 'source-map-loader',
                test: /\.js$/,
                enforce: 'pre'
            }
        ]
    },

    plugins: [
        new HtmlWebpackPlugin({
            template: path.join(__dirname, 'app', 'index.html'),
            favicon: path.join(__dirname, 'app', 'favicon.ico'),
            inject: 'body',
        })
    ],

    externals: {
        'react': 'React',
        'react-dom': 'ReactDOM'
    }
};

In case it’s not obvious, I’m using TypeScript (not sure how relevant that is):

"awesome-typescript-loader": "^3.0.0-beta.18",
"typescript": "^2.1.5",

I also have an NPM script to launch the server (npm run server):

"scripts": {
    "server": "./node_modules/.bin/webpack-dev-server --hot",
}

My app is currently very simple… I have the main React page (Index.tsx) which renders 2 components (CompA.tsx and CompB.tsx). When I change CompB, I expect the page to NOT full reload and instead just that component to reload. Is that what HMR is supposed to do, correct?

But there’s what I get when I change CompB.tsx:

image

I know there’s a recent issue (#741) about a similar problem and I looked into the suggested link (http://andrewhfarmer.com/webpack-hmr-tutorial/) but didn’t help. Since I’m using beta versions and TypeScript and those might have some impact on my exact problem, I decided to create a new issue. Hope it’s ok…

Any idea what am I doing wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rfgamaralcommented, Jan 27, 2017

@rpoitras Can you post a minimal configuration of your working setup so I could see what I need to do to get my own working? If possible without redux and react-router, not sure if those complicate things.

There’s so much misinformation lying around that I’m not sure what exactly is the proper setup to get HMR working.

But do you use TypeScript too?

0reactions
shellscapecommented, Aug 9, 2017

Pruning due to age, inactivity, and apparent solutions/workarounds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting XAML Hot Reload - Visual Studio (Windows)
If you want to use XAML Hot Reload with the Debug > Attach to Process command instead, then set the environment variable yourself....
Read more >
Hot reload not working - Visual Studio Feedback
I'm trying to use Hot Reload on Android Emulador, but when I do any change in XAML file, the app doesn't update. Looking...
Read more >
Unable to Hot Reload on Visual Studio 2022 - Stack Overflow
14 Answers 14 · Press the Hot Reload icon in the toolbar, then Settings from the icon's context menu (or access via Tools...
Read more >
Hot reload - Flutter documentation
If code changes affect the state of your app (or its dependencies), the data your app has to work with might not be...
Read more >
Edit running code with Hot Reload - JetBrains Rider
If you use Visual Studio keymap, you can press Alt+F10 to apply changes. For other keymaps, you can assign a custom shortcut to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found