简体   繁体   中英

Rails loading both app/assets and public/assets in development mode

If I precompile my assets locally, then the precompiled assets (public/assets) are served in addition to the unprecompiled assets (app/assets). I have tried adding

config.serve_static_assets = false

to my development.rb. The other asset configuration parameters in development.rb are:

config.assets.compress = false
config.assets.debug = true

Of course I can delete the public/assets folder, but I don't want to have to precompile the assets before every push -- that's why I started precompiling locally in the first place. Any ideas on how I can get Rails to only serve the nonprecompiled assets?

The best solution is probably to store your precompiled assets in different places for production and development. Leave them under public/assets for production, and set a different path for development like that:

# config/environments/development.rb
config.assets.prefix = '/dev/assets'

As you don't want to precompile your assets for development, that folder will be empty, and you'll end up loading only the assets from app/assets in development. And production will keep using the ones from public/assets .

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