带有多个清单文件的 Rails 4 Assets 预编译 [英] Rails 4 Assets Precompilation with multiple manifest files
问题描述
我有一个 rails 4 应用程序.
I have a rails 4 application.
我有 3 组清单文件,以便为我的应用程序分离逻辑.
I have 3 sets of manifest files in order to seperate out logic for my app.
这些文件是
application.js
backoffice.js
pos.js
application.css
backoffice.css
pos.css
在我的布局文件中,我使用关联的 javascript_link_tags 引用这些资源
In my layout files, I reference these assets using the associated javascript_link_tags
我已将以下内容添加到我的 production.rb 文件中(为了将这些文件包含在资产的预编译中):
I have added the following to my production.rb file (in order to include these files in the precompilation of assets):
config.assets.precompile += %w( backoffice.js pos.js pos.css backoffice.css )
然后我运行 rake assets:precompile,但它没有选择额外的文件.它只编译 application.js 和 application.css 清单.
I then run rake assets:precompile, but it is not picking up the additional files. It only compiles the application.js and application.css manifests.
也在 production.rb 中,我有:
In production.rb also, I have:
config.serve_static_assets = true
config.assets.compile = false
有人有什么想法吗?
谢谢
推荐答案
如果复制此行
config.assets.precompile += %w( backoffice.js pos.js pos.css backoffice.css )
到 config/application.rb
(Rails 4.0)(而不是 config/environments/production.rb
)它会工作.
to config/application.rb
(Rails 4.0) (instead of config/environments/production.rb
) it will work.
我从这里得到了一个提示:Rails 4 assets.precompile
I've got a tip from here: Rails 4 assets.precompile
正如评论中所建议的,在 Rails 4.2 中,您应该在 config/initializers/assets.rb
As suggested in the comments, in Rails 4.2 you should write above line in config/initializers/assets.rb
这篇关于带有多个清单文件的 Rails 4 Assets 预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!