Webpacker: rake task webpacker:clobber needed

Created on 27 Feb 2017  ·  16Comments  ·  Source: rails/webpacker

This should be like:

rake assets:clobber
    Remove compiled assets

Anybody agree? I can throw in a PR.

enhancement

Most helpful comment

I think a parallel clobber task makes sense. But, rails assets:precompile doesn't clobber assets so if rails webpacker:compile clobbers assets, then it would seem inconsistent and perhaps confusing to the user.

All 16 comments

@justin808 Yes, sounds good. Perhaps, this task is also run before assets are compiled by default so, we cleanup old files. I recall in react on rails you had a rm -rf app/assets/webpack in Procfile.

I think a parallel clobber task makes sense. But, rails assets:precompile doesn't clobber assets so if rails webpacker:compile clobbers assets, then it would seem inconsistent and perhaps confusing to the user.

@sealocal @gauravtiwari @rafaelfranca Does anybody know why assets:precompile does not clobber the /public/assets directory?

@gauravtiwari I agree that the webpacker:compile task should always clear out old assets. I cannot think of any reason why somebody would want to keep old assets around. For example, when switching from development to production testing, if you don't clobber, you'll get files both with and without hashes.

@justin808 a couple of thoughts on why assets:precompile might not wipe things. Let's think about a production deployment:

  • The clobber step always has to happen first. So if the compile fails you're going to be left with no assets.
  • Even if the compile doesn't fail, let's say you're caching some of your pages. Until the cache expires, your page may serve broken assets.

Both of these scenarios probably won't be a problem if you're set up correctly, but I'd guess reasons like this are why clobber isn't part of precompile by default (you can always add it to your build process yourself if needed.)

@dleavitt the second point is quite valid!

Even if the compile doesn't fail, let's say you're caching some of your pages. Until the cache expires, your page may serve broken assets.

So yes, I'd agree that we should keep it separate.

Also, should we have one clobber task that runs both?

maybe assets:clobber should run both, per the way assets:precompile works:
https://github.com/rails/webpacker/blob/master/lib/tasks/webpacker.rake#L148-L151

@dleavitt Yeah, that makes sense. On heroku or other container based deployments, this might not be a issue as each deploy is self-contained and doesn't affect the current version if fails, however having said that isn't for all cases so, perhaps we can do something like - assets:clean for packs, which I think is similar to what's been said earlier.

Attaching to assets:clobber like assets:precompile 👍

On Tue, Feb 28, 2017 at 4:54 AM, Gaurav Tiwari notifications@github.com
wrote:

@dleavitt https://github.com/dleavitt Yeah, that makes sense. On heroku
or other container based deployments, this might not be a issue as each
deploy is self-contained and doesn't affect the current version if fails,
however having said that isn't for all cases so, perhaps we can do
something like - assets:clean for packs, which I think is similar to
what's been said earlier.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/rails/webpacker/issues/131#issuecomment-282934896,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAKtfAfalpgGsU6pUtDSAbJP1h9ZmByks5rg5pmgaJpZM4MM1E-
.

I could do this. Do we have any way to assign tasks, to avoid duplication of efforts?

I think staking your claim in this thread is good enough 👍

I will do this after @gauravtiwari finishes #153 (unless he puts this in there), since the directories are configurable in his PR.

Hi @justin808 Do you have any plans to start this? I was thinking about something like sprockets's manifest.clobber and manifest.clean methods implemented in the Webpacker::Manifest class #clobber and #clean ...

@aganov Thanks for the ping. I'm going to check this out today. If I can't get to this by this evening HST, I'll hand this off to you if you like. Great pointers on the clobber and clean!

@aganov If you want to submit a PR for clean, that might be useful. Given the way the manifest.json works with webpacker, I'm not sure we want to keep old assets around per the sprockets algorithm.

PR #227 is pending review.

fixed by #227

Was this page helpful?
0 / 5 - 0 ratings