从资产中排除文件:在rails中预编译 [英] Excluding files from assets:precompile in rails
问题描述
我使用codekit编写较少的代码,然后将其自动转换为CSS.
I use codekit for writing less which it then converts to css automatically.
我不希望Rails将我较少的文件转换为css,而是使用codekit来完成.
I don't want rails to convert my less files to css, I rather codekit do it.
如果我通过以下方式预编译资产
if I precompile the assets via
rake assets:precompile
我知道
rake aborted!
cannot load such file -- less
如何排除特定的文件夹/文件类型以进行预编译? (我所有较少的文件都在app/assets/stylesheets/less中,而css(我确实希望对其进行预编译)在app/assets/stylesheets/css中
How do I exclude a specific folder/file types from precompiling? (all my less files are in app/assets/stylesheets/less and the css (which I do want to be precompiled) are in app/assets/stylesheets/css
更新
删除application.less
可以解决此问题,但是如何从一开始就将其排除在处理范围之外?
deleting application.less
solves this but how do I excluding it from processing in the first place?
推荐答案
来自资产管道指南:
用于编译文件的默认匹配器包括application.js, application.css和所有非JS/CSS文件(即.coffee和.scss 文件会自动编译为JS/CSS,因此不会自动包含在内:
The default matcher for compiling files includes application.js, application.css and all non-JS/CSS files (i.e., .coffee and .scss files are not automatically included as they compile to JS/CSS):
[ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) }, /application.(css|js)$/ ]
如果您还有其他清单或单独的样式表和JavaScript 要包含的文件,您可以将它们添加到预编译数组中:
If you have other manifests or individual stylesheets and JavaScript files to include, you can add them to the precompile array:
config.assets.precompile += ['admin.js', 'admin.css', 'swfObject.js']
所以,我想说您的解决方案是修改config.assets.precompile
以排除.less
文件.也许是这样的(在适当的环境文件中,例如config/environments/production.rb
):
So, I would say that your solution is to modify config.assets.precompile
to exclude .less
files. Maybe something like this (in a suitable environment file, like config/environments/production.rb
):
config.assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css', '.less']) }, /application.(css|js)$/ ]
这篇关于从资产中排除文件:在rails中预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!