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

pathMode (a.k.a. historyMode): Allow full-refresh by setting webpack properly #17

Open
Nordes opened this issue Mar 31, 2020 · 1 comment

Comments

@Nordes
Copy link

Nordes commented Mar 31, 2020

Hello Zaid, thank's for your great repository.

In order to allow the refresh in webpack on a url in history mode, we can set the following property in the devServer:

    devServer: {
        publicPath: "/",
        contentBase: resolve(CONFIG.assetsDir),
        port: CONFIG.devServerPort,
        proxy: CONFIG.devServerProxy,
        hot: true,
        inline: true,
        historyApiFallback: true // <=====
    }

ref.: https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback

This allow to not have the 404 error message and also allow refresh (F5). I prefer the history mode to hashes.

In such case, we might also want to add in the index.html the following:

        <base href="/" target="_blank">

This will find the JS at the root path (note that it can also be injected using webpack, but I guess it's to the developer to know that).

@Zaid-Ajaj
Copy link
Owner

Awesome stuff @Nordes, I will make sure to add these comments in the docs about pathMode routing. Thanks a lot 🙏

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

2 participants