This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
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.
Using esbuild to compile SCSS files works for the SCSS part, but not for assets that are referenced inside the SCSS files. Images are processed by the asset pipeline. The pipeline turns images like
foo.png
intofoo-138b348edbc780482d40f0abc5b57e487c0ecf24cfbde42d54007cfd8db0d7a4.png
. SCSS files still refer to them asurl("foo.png")
, but the final path to the image must include the hash in production. To make sure the final CSS file can find these images, sprockets-rails scans all CSS files usingAssetUrlProcessor
, which replacesurl("foo.png")
with the hashed version.Another complication was in a previous version of my asset pipeline esbuild located assets relative to the CSS file the refernced them. Sprockets doesn't look there. It searches any directory in
app/assets
. All the asset urls in SCSS files needed to be changed to be relative to those search paths instead, e.g.../../images/foo.png
tofoo.png
.I have three base css files: application, blog, and admin. To support them all I changed the
sass
command to look in./app/assets/stylesheets
and build to./app/assets/builds
instead of looking at each individual file (sass reference). It built theadmin.css
file inside of anadmin/
directory, so thestylesheet_link_tag
had to change to reflect that.Building asseets in development now either requires running the css, js, and rails server. You can use
bin/dev
to start all three, or start them manually:Other cleanup
I wasn't able to get normalize.css imported from the node modules, but I also removed it and it didn't seem to break anything. So I'm going to keep it removed, as well as remove the
normalize-rails
gem.Finally, I was able to remove the
esbuild-sass-plugin
node module since I'm not using esbuild to bundle sass anymore.