如何强制 rake assets:precompile 为生产 RefineryCMS 生成单独的 JS 文件? [英] How do I force rake assets:precompile to generate a separate JS file for production RefineryCMS?
问题描述
我正在使用 RefineryCMS,在管理部分我需要包含一个 JS 文件.为此,您必须设置一个配置值
I'm using RefineryCMS and in the admin section I need to include a JS file. To do that you have to set a config value
config.register_javascript "bootstrap.modal"
http://antonivanopoulos.com/refinerycms-admin_restyle-a-gem-to-make-refinery-cms-a-little-prettier/
它在开发中有效.当我为生产预编译资产时,RefineryCMS 管理页面给出 404 错误,因为 bootstrap.modal-7bc4667810e04a7a7ccf02099c81a882.js
在 public/assets 中不存在.相反,它嵌入在炼油厂管理员不使用的 application.js
中.
It works in development. When I precompile the assets for production, RefineryCMS admin pages give a 404 error because bootstrap.modal-7bc4667810e04a7a7ccf02099c81a882.js
doesn't exist in public/assets. Instead it's embedded in application.js
which Refinery admin doesn't use.
炼油厂将为该文件插入一个单独的 JS 标签:
Refinery will insert a separate JS tag for that file:
<script src="/assets/bootstrap.modal-b7d8ffab93a0b4c1ed4d9681ec6647f4.js" type="text/javascript"></script>
该文件作为应用资产存在,但不会作为自己的文件进行指纹识别.
The file exists as an app asset, but doesn't get fingerprinted as its own file.
$ ls app/assets/javascripts/bootstrap.modal.js
app/assets/javascripts/bootstrap.modal.js
$ rake assets:precompile
...
$ ls public/assets/boot*
ls: cannot access public/assets/boot*: No such file or directory
我不能只包含 application.js,因为还有很多东西会弄乱管理页面的显示.
I can't just include application.js because there is a lot more stuff that messes up the display of the admin pages.
我阅读了整个资产管道指南,但没有发现任何有用的内容.
I read the entire asset pipeline guide but found nothing useful.
http://guides.rubyonrails.org/asset_pipeline.html
Rails 3.2.14.
Rails 3.2.14.
推荐答案
我发现我可以将单独的文件添加到要编译的资产列表中,这样我就可以在生产中获得这些额外的文件.
I found I can add individual files to the list of assets to compile so I could get those extra files in production.
production.rb:
production.rb:
config.assets.precompile += %w( bootstrap.modal.js bootstrap.modal.css blog_post_form.js ) # This is for Refinery Admin /config/initializers/refinery/core.rb
这篇关于如何强制 rake assets:precompile 为生产 RefineryCMS 生成单独的 JS 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!