ndbroadbent / turbo-sprockets-rails3

Speeds up your Rails 3 assets:precompile by only recompiling changed files, and only compiling once to generate all assets
MIT License
975 stars 78 forks source link

changing a file imported with a wildcard does not trigger a re-compile #20

Closed goosetav closed 11 years ago

goosetav commented 11 years ago

sass allows imports using wildcards - @import foo/* - changes to file imported this way are not detected properly


example (see goosetav/turbo-trouble):

First, make sure we're in a "first run" state:

~/projects/turbo-trouble/app/assets/stylesheets # rm -rf ../../../public/assets/*
~/projects/turbo-trouble/app/assets/stylesheets # bundle exec rake RAILS_GROUPS=assets assets:precompile
(in /Users/erik/Documents/projects/turbo-trouble)
/Users/erik/.rbenv/versions/1.9.3-p286/bin/ruby /Users/erik/.rbenv/versions/1.9.3-p286/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
Compiled jquery.js  (3ms)  (pid 52061)
Compiled jquery_ujs.js  (0ms)  (pid 52061)
Compiled application.js  (10ms)  (pid 52061)
Compiled application.css  (12ms)  (pid 52061)
Processed digest assets in 1778ms
Copied binary asset to rails.png
Stripped digests, copied to application.js, and created gzipped asset
Stripped digests, copied to application.css, and created gzipped asset
Generated non-digest assets in 23ms

Example of @import that was fixed by #13 - this works great

~/projects/turbo-trouble/app/assets/stylesheets # echo -e ".matcher3 {\n  color: #FFF;\n}" >> _changeme3.scss 

~/projects/turbo-trouble/app/assets/stylesheets # bundle exec rake RAILS_GROUPS=assets assets:precompile
(in /Users/erik/Documents/projects/turbo-trouble)
/Users/erik/.rbenv/versions/1.9.3-p286/bin/ruby /Users/erik/.rbenv/versions/1.9.3-p286/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
Not compiling rails.png, sources digest has not changed (be8732d)
Not compiling application.js, sources digest has not changed (e569a8d)
Compiled application.css  (10ms)  (pid 52136)
Processed digest assets in 53ms
Copied binary asset to rails.png
Stripped digests, copied to application.js, and created gzipped asset
Stripped digests, copied to application.css, and created gzipped asset
Generated non-digest assets in 10ms

Making a change to a scss file imported through the @import "dir/*" -- this does not trigger a re-compile

~/Documents/projects/turbo-trouble/app/assets/stylesheets # echo -e ".matcher4 {\n  color: #FFF;\n}" >> changeme/_changeme2.scss

~/Documents/projects/turbo-trouble/app/assets/stylesheets # bundle exec rake RAILS_GROUPS=assets assets:precompile
(in /Users/erik/Documents/projects/turbo-trouble)
/Users/erik/.rbenv/versions/1.9.3-p286/bin/ruby /Users/erik/.rbenv/versions/1.9.3-p286/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
Not compiling rails.png, sources digest has not changed (be8732d)
Not compiling application.js, sources digest has not changed (e569a8d)
Not compiling application.css, sources digest has not changed (c22b417)
Processed digest assets in 38ms
Copied binary asset to rails.png
Stripped digests, copied to application.js, and created gzipped asset
Stripped digests, copied to application.css, and created gzipped asset
Generated non-digest assets in 11ms
goosetav commented 11 years ago

sidenote: glob imports are a feature added by sass-rails since 3.1 (see chriseppstein/sass-globbing)

ndbroadbent commented 11 years ago

Thanks for mentioning this! I've started working on glob support for @import, and it should be done pretty soon.

ndbroadbent commented 11 years ago

Hi there, this should all be fixed. Please update to 0.1.17 and let me know if you still experience any issues.

I've decided to back down from my monkey-patching approach, and just process the Sass / Less files if they contain an @import directive. Processing will only take an extra second or two, but the change detection will be completely bullet-proof, since all the registered importers will be run properly.

Thanks for your help!