Categories
React Answers

How to tell Webpack dev server to serve index.html for any route?

Spread the love

Sometimes, we want to tell Webpack dev server to serve index.html for any route.

In this article, we’ll look at how to tell Webpack dev server to serve index.html for any route.

How to tell Webpack dev server to serve index.html for any route?

To tell Webpack dev server to serve index.html for any route, we can set the historyApiFallback.index property to 'index.html'.

For instance, we write

devServer: {
  port: 3000,
  historyApiFallback: {
    index: 'index.html'
  }
}

to set the historyApiFallback.index property to 'index.html' to make the Webpack dev server serve index.html for any route.

Conclusion

To tell Webpack dev server to serve index.html for any route, we can set the historyApiFallback.index property to 'index.html'.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *