-
Notifications
You must be signed in to change notification settings - Fork 2k
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
File-loader: Output file-loader files in development #36337
Conversation
The fix for SSR file-loader URLs from #36204 caused a regression in development. This was due to the way `publicPath` is hard-coded in the server's webpack-dev-middleware. When in that environment, use matching output and public path.
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
isDevelopment && ! isDesktop | ||
? { | ||
outputPath: 'images/', | ||
publicPath: '/calypso/evergreen/images/', |
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 don't like the conditional configurations, but it seems necessary due to this:
wp-calypso/server/bundler/index.js
Line 104 in 53be70d
publicPath: '/calypso/evergreen/', |
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.
This LGTM 👍 Thanks for the fix!
// Build off `output.path` for a result like `/…/public/evergreen/../images/`. | ||
outputPath: path.join( '..', 'images' ), | ||
publicPath: '/calypso/images/', | ||
emitFile: browserslistEnv === defaultBrowserslistEnv, // Only output files once. |
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.
Was it intentional to remove the emitFile
option? It prevents writing the same files twice when doing parallel evergreen/fallback builds.
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 did remove it intentionally because I had some concerns about the fragility of writing it once and hoping that the default always runs. I'm not sure how expensive these redundant writes are.
We can restore it if you prefer.
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'm a bit worried about the files getting corrupted when two processes at once try to write them. No so much about performance really. I'd prefer to restore them. And always emitting in development, i.e., leaving the emitFile
option undefined there.
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.
👍 Restored in e2c7c66
It took me a while to figure out what's going on here 🙂 In dev mode, the images are not written to disk: |
Pushed one more fix in e01cd6e:
|
Running
npm start
would result in file-loader requests 404ing. Reported in #36204 (comment).This is due to the server bundler's webpack-dev-middleware, which hard codes a
/calypso/evergreen/
public path.This change updates the file-loader in development to match the expected path.
Testing instructions