Skip to content

Conversation

@5im-0n
Copy link
Contributor

@5im-0n 5im-0n commented May 2, 2019

This pr adds a spa.serve-existing command line option to serve all static files as assets, without the need to specify a spa.asset-test option.
This allows to serve spa apps that use dots (.) and other special characters in the path portion of the url, without the need to specify complex asset-test regular expressions.

@5im-0n 5im-0n force-pushed the serve-existing branch from ab4aa21 to 66df9d7 Compare May 2, 2019 18:39
@75lb
Copy link
Member

75lb commented May 20, 2019

so with --spa.serve-existing enabled, ws will do file system I/O for every incoming HTTP request, regardless what it's for. So you'll be doing constant filesystem I/O for existance of files with names like /one/two/53%C2%B031'22.0%22N+2%C2%B013'21.0%22W/@53.5227778,-2.2246887,17z/data=!3m1!4b1!4m5!3m4!1s0x0:0x0!8m2!3d53.5227778!4d-2.2225 etc.

I'm not yet convinced this is 100% efficient and should baked into ws..

@5im-0n
Copy link
Contributor Author

5im-0n commented May 20, 2019

It's the same as the -f in Apache RewriteCond: https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
It's not really efficient, but it's the only way to serve SPA apps that don't have an explicit /api/ endpoint for apis. Maybe we can add it to the documentation that it's not efficient because it does filesystem I/O for every request and should only be used while developing?

@75lb 75lb merged commit f042400 into lwsjs:master May 20, 2019
@75lb
Copy link
Member

75lb commented May 21, 2019

Released in lws-spa v1.0.0. The option is now called --spa.asset-test-fs to indicate it's part of the same option family as --spa.asset-test.

It's not yet included in the default ws middleware stack but you can test it locally with commands like this:

npm i -D local-web-server lws-spa

# prints help for a custom stack using just the local lws-spa installation and lws-static.
# You should see the docs for `--spa.asset-test-fs`.
npx ws --stack ./node_modules/lws-spa lws-static --help 

# runs the custom stack - use this command to test the new feature
npx ws --stack ./node_modules/lws-spa lws-static --spa.asset-test-fs --spa your-spa-here.html

Let me know if you have any issues.

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

Successfully merging this pull request may close these issues.

2 participants