Ruby Nanoc+;Bower=错误-为找到2个内容文件
我正在使用nanoc生成一个静态站点 最近,我添加了管理前端依赖项的功能 当我通过Bower添加引导程序时,我将包放在Ruby Nanoc+;Bower=错误-为找到2个内容文件,ruby,bower,nanoc,Ruby,Bower,Nanoc,我正在使用nanoc生成一个静态站点 最近,我添加了管理前端依赖项的功能 当我通过Bower添加引导程序时,我将包放在/assets/Bower/ 引导程序包包含多个文件,包括: bootstrap/js/tests/vendor/qunit.css bootstrap/js/tests/vendor/qunit.js 我的规则文件包含以下规则: route '/assets/*' do extension = item[:extension] if extension == 'cof
/assets/Bower/
引导程序包包含多个文件,包括:
bootstrap/js/tests/vendor/qunit.css
bootstrap/js/tests/vendor/qunit.js
我的规则
文件包含以下规则:
route '/assets/*' do
extension = item[:extension]
if extension == 'coffee'
extension = 'js'
end
item.identifier.chop + '.' + extension
end
compile '*', :rep => :spec do
if !item[:spec_files].nil? && !item.binary?
filter :erb
layout 'spec'
end
end
route '*', :rep => :spec do
if !item[:spec_files].nil? && !item.binary?
'/specs' + @item.identifier[0..-2] + '.html'
end
end
compile '*' do
if !item.binary?
filter :erb
layout_name = item[:layout] || 'default'
layout layout_name
end
end
route '*' do
if item.binary?
item.identifier.chop + '.' + item[:extension]
else
item.identifier[0..-2] + '.html'
end
end
运行nanoc
时,出现以下错误:
RuntimeError: Found 2 content files for
content/assets/bower/bootstrap/js/tests/vendor/qunit; expected 0 or 1
我尝试为/assets/bower/文件夹添加2个新的“空”规则,但仍然出现错误
route '/assets/bower/*' do
end
compile '/assets/bower/*' do
end
有什么建议吗
以后编辑:
看起来nanoc支持一个静态数据源,它还考虑了文件扩展名
仍然不确定是否可以并行使用这两个数据源。不幸的是,在最后一个扩展名之前,同一目录中不能有两个同名的文件。对于Nanoc4.0,它将被重写以改变这一点 您肯定可以同时使用多个数据源,但这意味着您不能对
qunit
文件应用过滤器,只能重定向输出
您是否明确要求能够像Bower安装文件一样组织文件?如果可以的话,最好将它们分为脚本
和样式
——无论如何,您几乎肯定会根据文件类型进行筛选,这意味着在规则中您可以直接使用
compile '/whatever-path/scripts/' do
filter :concatenate
filter :uglify_js
end
而不是
compile '/whatever-path/ do
case item[:extension]
when 'js'
filter :uglify_js
when 'scss'
filter :sass
end
end
不幸的是,在最后一个扩展名之前,同一目录中不能有两个同名文件。对于Nanoc4.0,它将被重写以改变这一点 您肯定可以同时使用多个数据源,但这意味着您不能对
qunit
文件应用过滤器,只能重定向输出
您是否明确要求能够像Bower安装文件一样组织文件?如果可以的话,最好将它们分为脚本
和样式
——无论如何,您几乎肯定会根据文件类型进行筛选,这意味着在规则中您可以直接使用
compile '/whatever-path/scripts/' do
filter :concatenate
filter :uglify_js
end
而不是
compile '/whatever-path/ do
case item[:extension]
when 'js'
filter :uglify_js
when 'scss'
filter :sass
end
end