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

Multiple config + devServer + different HMR options don't work #1955

Closed
Jack-Works opened this issue Oct 16, 2020 · 8 comments
Closed

Multiple config + devServer + different HMR options don't work #1955

Jack-Works opened this issue Oct 16, 2020 · 8 comments
Labels

Comments

@Jack-Works
Copy link

Describe the bug

I try to use 2 configs that one uses HMR and the other one doesn't. It doesn't work.

To Reproduce

package.json

{
    "dependencies": {
        "webpack": "^4.44.2",
        "webpack-cli": "^4.0.0",
        "webpack-dev-server": "^3.11.0"
    }
}

webpack.config.js

module.exports = () => {
    return [
        { mode: "development", entry: { a: "./a.js" }, devServer: { writeToDisk: true, hot: true, port: 4858 } },
        {
            mode: "development",
            entry: { b: "./b.js" },
            devServer: { writeToDisk: true, hot: false, injectClient: false, port: 4868, injectHot: false },
        },
    ];
};

a.js and b.js empty

Run webpack serve

Expected: The dist/b.js don't have HMR related code

Actual: It has

@Jack-Works Jack-Works added the Bug label Oct 16, 2020
@topocount
Copy link

topocount commented Oct 16, 2020

I've also found this to be true with the inline: false config. before upgrading to v4, webpack wouldn't attempt to inject the client (HMR/ auto-refresh) code into files and now it's attempting to do so. The upshot of this is that SSR files/environments don't have the ability handle this code without shims

@alexander-akait
Copy link
Member

inline was removed in the next version, don't use it, never

@topocount
Copy link

topocount commented Oct 16, 2020

@evilebottnawi Thanks, good to know. I don't see this reflected in the docs (v4 or v5) yet, though, or in the form of a CLI config parsing error or warning for that matter (which I've appreciated as being particularly thorough).

@alexander-akait
Copy link
Member

Expected, you have hot: false and injectHot: false for the second config, so no HMR for this

@Jack-Works
Copy link
Author

Expected, you have hot: false and injectHot: false for the second config, so no HMR for this

@evilebottnawi hi please read again. my expectation is that has no HMR for the second config, but it has

@alexander-akait
Copy link
Member

My mistake

@Jack-Works
Copy link
Author

I have workaround this problem by providing a function to injectHot and injectClient. But still hope this can be resolved.

@alexander-akait
Copy link
Member

Duplicate #2408, we need improve multiple dev servers support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants