Serve-static option: 'extensions'#539
Conversation
|
@bitjson Thanks for the contribution. Yes, we can easily add serve-static's option, but this looks bad practice for me. In this case you can launch a new server which works as you expected and use browser-sync with |
|
@shinnn, thanks for the awesome project. I definitely agree with keeping browser-sync's static server as simple as possible. I think this falls in the area browser-sync should support "out of the box" because it's a standard option of serve-static. It seems unnecessary for projects to have to re-include a separate instance of serve-static in I wanted to avoid make too many changes for this pull request (I think this is important functionality, and I'd love to see it included sooner than a more significant change would allow), but I think a future pull request could simplify everything by exposing serve-static's options and making browser-sync indifferent to the specifics. Since serve-static is very commonly used, it would probably also be more accessible for new browser-sync users to:
If there's any interest (?), I could work on that in another pull request. |
|
@shinnn - I understand your reservations - but I think this is a special case as we already allow certain options to pass through anyway. @bitjson - I think, as you alluded to, this is a good opportunity to disconnect from handling any serve-static configuration by just passing a new hash straight through. We cannot allow a top level property however as we use that namespace for middleware/routes, but I decided upon the following for clarity. server: {
baseDir: "./app",
serveStaticOptions: {
/* passed directly to serve-static */
}
}No mistake can be made here, it doesn't interfere we anything we are already doing and it can safely be introduced without breaking anything. |
|
That looks like an excellent solution, thanks! And I appreciate the nod, thank you. Looking forward to it landing. |
|
:) |
|
Impressive turnaround, thanks! |
|
It was just good timing as I've been pushing to release http://quick.as/j1of99bb :) |
|
Browser-sync just keeps getting better and better. Nice work! |
Allows the use of
serve-static'sextensionsoption.This adds the option to
utils.addBaseDir, adds a cli option, and adds the option toe2e.cli.server.js.usage
cli usage
$ browser-sync start --server build --extensions 'json'