serve
serve copied to clipboard
Rewrites not being applied.
I have a use case where the libraries that are being produced by the monorepo (NX) have different base paths.
I would like to use this library to serve locally those builds for debugging.
However, right now if I just serve the folder of the build it doesn't work. I have to change the content of the base tag manually from
I would like to handle this as a part of the serve
config.
Here's the way I call the serve
and my setup:
serve -s ./dist/apps/thing-form -c ./serve.json
{
"rewrites": [{ "source": "/thing/form", "destination": "/dist/apps/thing-form/index.html" }]
}
The application is a react spa so what should be resolved are static resources. The inner routing is handled by the application.
With this setup and the way I call it, I don't see any effect of the serve.json file.
I have the same problem, have you found a solution
Unfortunately, I have not. This is still on hold for me.
I also have this issue.
I figured it out. Basically, if you are using the -s
argument to specify the directory to run within, the path rewriting will not work.
However, if you cd
to the directory you wish to serve, and then run the serve command, the rewrites will work as expected.
TL;DR:
Instead of This:
yarn run serve -s [DIRNAME] ...
Do This:
cd [DIRNAME] && yarn run serve ...
Maintainers, I think we could really use some dev lift on this one -- as it's not made clear that using the -s
argument will break the serve.json file default behavior.
I'd also be happy to take a look myself if you can point me to where the issue likely lies :)
fwiw, it doesn't look like the -s
flag is being used correctly.. which is shorthand for --single
.. which is a boolean that causes all requests to redirect to the virtual pathname: /index.html