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

Fixed HMR on Windows #1995

Merged
merged 1 commit into from May 2, 2019

Conversation

Projects
None yet
3 participants
@edcoreweb
Copy link
Contributor

commented Feb 13, 2019

Currently on Windows HMR does not work:

How to reproduce:

  • delete js/css outputs
  • run npm run hot

You will get 404 errors.

The following section: path.resolve(Mix.isUsing('hmr') ? '/' : Config.publicPath)
will result on D:\\ instead of the expected /, where D is the windows drive letter.

Expected: (linux, mac)

output: {
  path: '/',
  filename: '[name].js',
  chunkFilename: '[name].js',
  publicPath: 'http://localhost:8080/'
}

Windows:

output: {
  path: 'D:\\',
  filename: '[name].js',
  chunkFilename: '[name].js',
  publicPath: 'http://localhost:8080/'
}

This fixes: #1993

@cretueusebiu cretueusebiu referenced this pull request Mar 12, 2019

Closed

HMR #163

@jlsjonas

This comment has been minimized.

Copy link

commented Mar 22, 2019

🙇 This fixed HMR not working on windows for me

I hope it'll get merged soon as I had to waste yet another 2 hours when the workaround found in one of the related issues' comments stopped working.

I did still need to remove the leading / workaround for HMR itself to work (otherwise I'd need a page refresh, but files were being served) (FYI: a recent update removed the need for this, leaving it here for future reference)

Mix.listen('configReady', webpackConfig => {
    if (Mix.isUsing('hmr')) {
        // Remove leading '/' from entry keys
        webpackConfig.entry = Object.keys(webpackConfig.entry).reduce((entries, entry) => {
            entries[entry.replace(/^\//, '')] = webpackConfig.entry[entry];

            return entries;
        }, {});

        // Remove leading '/' from ExtractTextPlugin instances
        webpackConfig.plugins.forEach(plugin => {
            if (plugin.constructor.name === 'ExtractTextPlugin') {
                plugin.filename = plugin.filename.replace(/^\//, '');
            }
        });
    }
});
@jlsjonas

This comment has been minimized.

Copy link

commented May 2, 2019

@JeffreyWay Could you consider merging this please? Meanwhile this has to be manually re-patched with every update

@laracasts laracasts merged commit 6a2c949 into JeffreyWay:master May 2, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.