rails / sprockets-rails

Sprockets Rails integration
MIT License
575 stars 244 forks source link

Rake task for completely clear assets cache #391

Open ypresto opened 7 years ago

ypresto commented 7 years ago

Clearing tmp/cache/assets is necesasry to regenerate assets correctly, but rails assets:clean or rails assets:clobber does not clear tmp/cache/assets. I spent hours to solve cache issue after changing config.assets.prefix...

While it can be done with tmp:cache:clear, I think it'd better to have own task to clear that dir to avoid confusion.

Possible solutions:

Related issues

It was previously part of assets:clean: https://github.com/rails/rails/pull/2448

There are similar reports on other (wrong) repos: https://github.com/twbs/bootstrap-sass/issues/550 https://github.com/rails/sass-rails/issues/118

Document for clearing cache was improved in this PR: https://github.com/rails/sprockets-rails/pull/335

wjordan commented 7 years ago

If I understand correctly, this issue might be resolved by rails/sprockets#257, which changes the assets:clobber task to also clear the Sprockets cache store (tmp/cache/assets) in addition to all precompiled assets.

Could you try this task using master version of sprockets (no release has been published yet since this PR has been merged) and see if it fixes your issue?

TaylorJalpha commented 5 years ago

Clearing tmp/cache/assets is necesasry to regenerate assets correctly, but rails assets:clean or rails assets:clobber does not clear tmp/cache/assets. I spent hours to solve cache issue after changing config.assets.prefix...

While it can be done with tmp:cache:clear, I think it'd better to have own task to clear that dir to avoid confusion.

Possible solutions:

  • Add assets:clear-cache task to run rm -rf tmp/cache/assets.
  • Add assets:clean-all task to run clobber and rm -rf tmp/cache/assets.
  • Add reference to tmp/cache/assets or tmp:cache:clear to the document.

Related issues

It was previously part of assets:clean: rails/rails#2448

There are similar reports on other (wrong) repos: twbs/bootstrap-sass#550 rails/sass-rails#118

Document for clearing cache was improved in this PR:

335

@taylorjalpha