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 new CSS assets not being used after a rebuild #1100

Merged
merged 5 commits into from
Sep 21, 2021

Conversation

snowteamer
Copy link
Collaborator

Closes #1099

Fixes the relevant issue by copying new main.css and main.css.map over to the correct location.

@snowteamer snowteamer self-assigned this Sep 16, 2021
Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @snowteamer. I left a question.

Gruntfile.js Outdated
Comment on lines 429 to 435
if (['.css', '.sass', '.scss'].includes(extension)) {
// Esbuild outputs `main.css` and `main.css.map` along `main.js`,
// but `index.html` wants to load them from `dist/assets/css`.
await fs.promises.copyFile(`${distJS}/main.css`, `${distCSS}/main.css`)
if (buildMain.options.sourcemap) {
await fs.promises.copyFile(`${distJS}/main.css.map`, `${distCSS}/main.css.map`)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very granular of a way to do it, very specific to esbuild as well, which will make it more difficult to close #1085, I think. Have you considered doing it using the existing grunt-contrib-copy stuff that we have, or in a more generic way that is less specific to esbuild integration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, and it also introduces a bit of code duplication since the same copying operation occurs on the first build.

So I've considered specifying this post-build operation as a custom option, then thought it was better to keep things simple for now; but I should be able to add it if you don't mind the extra option.

I it is also possible via grunt copy, but I think it would still be as much specific to esbuild as plain code, and likely a bit slower. I'm also slightly reluctant to increase our dependency to Grunt since we might want to switch to Snowpack later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the post-build option would help with #1085 and DRY the code more?

If so, then I think it's worth doing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so since this copying operation might not be needed with other build tools, or they might require doing something else.

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the convo here: https://github.com/okTurtles/group-income-simple/pull/1100/files#r710204644

Implement the copying part using a post-build option to DRY things and help with #1085

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! Great catch @snowteamer! (My bad for not catching it originally!)

@taoeffect taoeffect merged commit b4b71a0 into master Sep 21, 2021
@taoeffect taoeffect deleted the fix-maincss-refresh branch September 21, 2021 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New CSS assets are not used after a rebuild
2 participants