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'
.