-
Notifications
You must be signed in to change notification settings - Fork 147
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
[V2] Implement dev server serveStaticFile #580
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c683815
implement dev serveStaticFile
kevinxh 9b255e7
serve favicon in typescript template
kevinxh b802543
add test
kevinxh 4eacf57
Merge branch 'v2' into v2-serveStaticFile
kevinxh f0d1943
move mock closer to test case
kevinxh 98ea00c
Merge branch 'v2-serveStaticFile' of https://github.com/SalesforceCom…
kevinxh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remote server already has code to handle the
favicon
. So technically there are 2 handlers being setup for the when running remote, once here on line 43 of ssr.js and the second time inside thebuild-remote-server.js
file below:pwa-kit/packages/pwa-kit-runtime/src/ssr/server/build-remote-server.js
Line 572 in 9b255e7
We should probably do something about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also.. why are we removing the serving of the
robots.txt
file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another reason why it might not make sense to have this line of code in ssr.js is because
faviconPath
is an option for the dev/remote servers. It would be odd to have that option but not do anything with it behind the scenesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question... sorry i didn't explain that in my PR description.
Serving favicon is exactly the same as serving any static files. Since we are adding programmatic APIs like
serveStaticFile
andserveServiceWorker
, I feel like it's better to keep things consistent, . If developers can already serve all static files including favicon viaserveStaticFile
, why do we need to have a specific configuration optionfaviconPath
? It almost feels like thefaviconPath
adds unnecessary complexity to the users. And it feels wrong to have two approaches (configuration and programatic API) to basically do the same thing.So, I want to propose that we remove
faviconPath
, and since @shethj is already working on the favicon ticket. I can work with @shethj to remove the option in his PR. I use favicon as an example in this PR, because that's the only static file in the template.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no robots.txt in the typescript template, so that endpoint is a 404, and I feel it's unnecessary for a "minimal" template to have robots.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to have robots and favicon work the same way. So that is cool with me. You'd just have to make sure you remove all that special logic in the remote server factory.
But one thing that I'm curious about is your implementation of the
serveStaticFile
for the dev server factory. It's completely different from the implementation in the remote server factory and I wasn't expecting that, since I assumed that the only real issue was the fact that the build dir was set tobuild
for remote and it should be something like `` for development. Lets have a small chat, later and se can talk about that a bit.