New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPA setting: ignore files with extensions #142
SPA setting: ignore files with extensions #142
Conversation
When running our app we do want requests like `/123/` to be converted to `/#/123`, however things like `/style.css` or `/foo.png` should be ignored. This commit changes the behaviour for the spa setting so it only applies to requests without an extension.
This sounds reasonable, but I don't use the SPA feature myself so I would like to hear some other comments. Also, I'm not keen on breaking changes... |
👍 understood. I appreciate not wanting a breaking change so I can definitely update this to need another flag. |
@tapio I have now updated to include |
This solution is not quite complete, what if someone would want |
@pavel I just went for the most straightforward approach to get it working. I guess you could have a @tapio I don't know what you want to do here; I equally understand if you want to just not take this PR, in which case I'll maintain my version as a fork (as we're using it successfully at work), but if you would be open to either what I've done so far or something closer to @pavel's idea to allow users more control, just let me know. |
@jackfranklin I do completely understand your point, I maintain my own fork with HTTP/2 support. But, please, understand that this is a general tool, it should work for everyone not just me and you. It is up to @tapio to decide what to do with this PR. Don't think I'm being bossy here or not like what you did, just want to make this tool as helpful as possible. |
@pavel I'm not saying it shouldn't work for everyone :) Just trying to find the best approach that doesn't make the config really complex. I think maybe we could actually do both:
@tapio what do you think? If the above sounds too complex I understand and I'm happy for the PR to be closed. It's your module :) |
This addition will allow people who want to control the SPA URL rewriting fully do so. This PR means you can pass: - `spaIgnoreAssets: true` (or `--spa-ignore-assets`) to not rewrite ANY URLs that contain a file extension - `spaIgnoreAssets: function(req) {...}` a function that should: - return `true` when the asset should be ignored - return `false` when it shouldn't be ignored
@pavel I've now updated this PR so @tapio please let me know if you would potentially merge this. If not, no worries, but I'll then maintain a fork (we need this at work), and endeavour to keep it up to date. I'd love any thoughts or feedback. I think with this latest change it works for everyone:
|
I wouldn't rush this, as I was working on @jackfranklin If you really need this like right now, I would recommend adding this right now. We'll still be able to deprecate it as soon as proper |
@pavel I'm happy to contribute / work with you on the rewrite option. I didn't see #146, that looks awesome! We're using my fork at work but would love to get back onto stable, especially with 146 and the speed up it gives. I can rework this PR or open a new one that adds the rewrite option, if you want to share your thoughts on how it should work. @tapio I've used this library for ages and I'm happy to contribute if you'd like more people to spread the load. |
@jackfranklin Please, see #149. |
Thanks for the contribution and discussion, but now that I have thought about this more I'm going to reject this PR for the following reasons:
That being said, I still want to support this usage of live-server. @pavel's URL rewrite functionality is one way to do that, which can be supported by adding spa examples to readme / wiki. However, I think a simple improvement of allowing specifying middleware files from cli would open up an awesome way to extend live-server while keeping the core code nice and tidy. We could even ship the separate middleware modules with live-server (instead of just sharing them in a wiki). So this PR's functionality would look something like The callback function version of the spa thingy can already be implemented by using the middleware node api parameter (with slight more code than in this PR, but in a much more generally useful way). |
@tapio that sounds good, I like the idea of middleware. I'm happy to work on this 👍 |
The basic version of middleware based |
When running our app we do want requests like
/123/
to be converted to/#/123
, however things like/style.css
or/foo.png
should beignored. This commit changes the behaviour for the spa setting so it
only applies to requests without an extension.
This is a breaking change - I did also think if you were not so keen on this we could introduce a new configuration setting / CLI flag?