简体   繁体   中英

Rails 5- Difference between RAILS_ENV=production rake assets:precompile and rake assets:precompile

I am new to Rails and even new to production.

What is the difference between RAILS_ENV=production rake assets:precompile and rake assets:precompile ? Isn't precompile supposed to be only in production? Why does rake assets:precompile produce nothing but RAILS_ENV=production rake assets:precompile produces a bunch of

I, [2019-01-07T20:45:55.090716 #14756]  INFO -- : Writing E:/abcd/public/assets/home-0b9b55ca1e7f939be5941a6b148eb88810cf0357d3e6a5c03702654c2a9e2886.css

In rails, each environment is just a configuration file. You can launch your app in different modes, and the modes are called environments because they affect the app's behavior in different ways. At the end of the day, they are just configuration files.

rails default environments are 1) development 2) production 3) test

but you can have as many as you want.

This link will help you understand environments https://guides.rubyonrails.org/configuring.html a bit better.

1) RAILS_ENV=production rake assets:precompile you are running this on your local computer but event that the default environment is development you want to simulate production. RAILS_ENV=production will read the options that are found in ** config/environments/production.rb ** if you leave it default it will use the systems environment

On Heroku, if you go to settings > Reveal Config Vars you will see its set to production, but you can change that. The same way that you can change it on your localhost.

I hope that this helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM