Uncompile Development Asset Pipeline
Asked Answered
M

4

47

I was compiling my asset pipeline for my production environment and it did for all my environments. How can I uncompile my asset pipeline for my development environment?

I have checked my config/development environment and cannot find a fix.

Thanks in advance for any help...

Misdoubt answered 19/12, 2011 at 3:29 Comment(0)
W
91

To remove precompiled assets use:

rake assets:clean

What this basically does is remove the public/assets directory. You may need to include the RAILS_ENV variable if you need to run it for a certain environment.

Whin answered 20/12, 2011 at 11:31 Comment(6)
This didn't work for me. I had to issue RAILS_ENV=development bundle exec rake assets:clean.Harrietteharrigan
also, be sure to clear your browser cache. even after you've restarted your server, the pages served up may still include a cached copy of the compiled application.js fileDubitation
Neither worked here, had to remove the entire public/assets folder.Avion
Did you put this line in your application.js '//= require_tree .' and this line in application.css '*= require_tree .' You need to to it.Godly
Or just remove your folder public/assetsGodly
I'm not sure why they changed the syntax for Rails 4 to rake assets:clobberWeakly
V
47

Try using

rake assets:clobber

worked for me in rails 4

Vikiviking answered 1/12, 2014 at 16:29 Comment(3)
Care to explain why this works? Until then I cannot vote up your answer and frankly few people will, SO answers should help people understand the issue not just provide a line of code.Sexagesima
It deletes compiled assets. You can also manually remove them, this is just a shortcut.Vikiviking
God bless your noble soul!Lanneret
E
5

When you run the compile task locally (on your development machine) the assets are compiled in the Rails production environment, but are written to the public folder.

This means that even when you run in development mode it'll use the compiled assets instead of sending requests to the pipeline. This is normal behavor - requests only go to the pipeline if the file does not exists in public/assets.

The compile task should generally only be used when deploying, and on the remote (production) machine.

If you have compiled locally, you can delete all the files in the public/assets folder and development will behave as before. If you checked these files into source control you'll need to remove them.

Once removed things should work fine. s One final tip: if this is an upgraded app check your config settings against those in the last section of the Rails asset pipeline guide.

Ellynellynn answered 19/12, 2011 at 4:38 Comment(1)
At least this answer doesn't just provide a one line code answer, but attempts to explain.Sexagesima
S
5

For Rails 5:

$ RAILS_ENV=development bin/rake assets:clobber
Shutin answered 5/6, 2017 at 17:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.