Skip to content
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

fix(gatsby): don't output file-loader assets to .cache #37284

Merged
merged 4 commits into from
Dec 19, 2022

Conversation

pieh
Copy link
Contributor

@pieh pieh commented Dec 16, 2022

Description

Currently file-loader / url-loader emits duplicate to seperate locations:

  • public/static:

    image

  • .cache/page-ssr/routes/static:

    image

public/static is where we want assets to go, as those are the assets that will be uploaded. This outpath is used during build-javascript or develop stage.

.cache/page-ssr/routes/static is result of using output settings for build-html / develop-html (

case `build-html`:
case `develop-html`:
// Generate the file needed to SSR pages.
// Deleted by build-html.js, since it's not needed for production.
return {
path: directoryPath(ROUTES_DIRECTORY),
)

This PR adjust url-loader and file-loader for build-html and develop-html stages to output to public while preserving what urls are generated.

Alternatively there is option to skip asset emission ( https://v4.webpack.js.org/loaders/file-loader/#emitfile ), but I figured that changing output location could be beneficial in case there might not be full overlap between html gen bundle and browser bundle. Skipping emission would not result in regression versus what we have now, but adjusting the outputpath might fix some possible edge cases we might have today.

Documentation

Related Issues

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Dec 16, 2022
@pieh pieh added topic: render-mode Related to Gatsby's different rendering modes and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Dec 16, 2022
@pieh pieh marked this pull request as ready for review December 19, 2022 07:48
@pieh pieh merged commit 3cbad19 into master Dec 19, 2022
@pieh pieh deleted the fix/build-html-output-file-loader-assets-to-public branch December 19, 2022 14:51
pieh added a commit that referenced this pull request Dec 20, 2022
* fix(gatsby): don't output file-loader assets to .cache

* use adjusted settings also for develop-html stage, as that one uses ROUTES_DIRECTORY too

* update comment

* some types for file-loader common options

(cherry picked from commit 3cbad19)
pieh added a commit that referenced this pull request Dec 20, 2022
* fix(gatsby): don't output file-loader assets to .cache

* use adjusted settings also for develop-html stage, as that one uses ROUTES_DIRECTORY too

* update comment

* some types for file-loader common options

(cherry picked from commit 3cbad19)
pieh added a commit that referenced this pull request Dec 20, 2022
* fix(gatsby): don't output file-loader assets to .cache

* use adjusted settings also for develop-html stage, as that one uses ROUTES_DIRECTORY too

* update comment

* some types for file-loader common options

(cherry picked from commit 3cbad19)

Co-authored-by: Michal Piechowiak <[email protected]>
pieh added a commit that referenced this pull request Dec 20, 2022
* fix(gatsby): don't output file-loader assets to .cache

* use adjusted settings also for develop-html stage, as that one uses ROUTES_DIRECTORY too

* update comment

* some types for file-loader common options

(cherry picked from commit 3cbad19)

Co-authored-by: Michal Piechowiak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: render-mode Related to Gatsby's different rendering modes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants