Sample repo demonstrating the issue is here.
I'm trying to set up webpack dev server so that:
- Requests to
/
are served bypublic/landing.html
(a static landing page) - Requests to anything else are served by my React app
Using create-react-app
, and based on webpack-dev-server
's options, I've set up my webpackDevServer.config.js
as follows:
historyApiFallback: {
// Paths with dots should still use the history fallback.
// See https://github.com/facebookincubator/create-react-app/issues/387.
disableDotRule: true,
rewrites: [
// shows views/landing.html as the landing page
{ from: /^\/$/, to: 'landing.html' },
// shows views/subpage.html for all routes starting with /subpage
{ from: /^\/subpage/, to: 'subpage.html' },
// shows views/404.html on all other pages
{ from: /./, to: '404.html' },
],
},
And when I start webpack here's what I see:
- Requests to
/subpage
are routed correctly tosubpage.html
- Requests to
/foo
are routed correctly to404.html
. Eventually, these would be handled by my React app. - Requests to
/
are routed incorrectly to my React app.
How can I get landing.html
to respond to requests at /
?