问题描述
问题,您如何让资产管道编译所有 .css 和 .js?
Question, how do you get all .css and .js to be compiled by the asset pipeline?
我试过了
config.assets.precompile += %w(*.css, *.js)
这样就可以预编译所有 .js.但由于某种原因,.css 文件没有编译.
and that got all of the .js to precompile. But for some reason the .css file is not compiling.
建议?
推荐答案
对于尝试自己做这件事的人来说,答案与选择器的格式有关.预编译采用一个选择器数组,选择器应该是字符串,所以你可以这样做
For anyone trying to do this yourself, the answer had to do with the format of the selectors. precompile take an array of selectors, and the selectors are supposed to be strings, so you could do
config.assets.precompile += ['*.css', '*.js']
获取所有要预编译的 css 和 js 文件.您可以将此逻辑扩展为更加规范,例如,我能够将所有 css 分组到 3 个清单文件中,但仍然发现能够包含任何 .js 更具扩展性,尽管有几个清单 .js 文件减少在最热门网页上的调用次数.
to get all css and js files to precompile. You can extend this logic to be more taylored, for example, I was able to group all of the css into 3 manifest files, but still found it more extensible to be able to include any .js, though there were several manifest .js files to make fewer calls on the most popular pages.
config.assets.precompile += ['logged.css','forum.css','editor.css', '*.js']
这篇关于css 资产未在生产中预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!