我目前正在尝试使用一些动态变量渲染scss文件。在我的本地机器上一切正常。在Heroku上我得到了这个错误:
Error: File to import not found or unreadable: bower_components/sass-mixins/mixins
const fs = require('fs');
const sass = require('node-sass');
var path = 'assets/compiled/' + client.id + '.css';
var dynamic = '$brand-primary: #CCC;';
fs.readFile('assets/scss/application.scss', function(err, data) {
sass.render({
data: dynamic + data,
includePaths: [
__dirname + '/../../',
__dirname + '/../../bower_components'
]
}, function(err, result) {
// do sth. with result
});
});
我已经使用includePaths
添加了process.cwd()
,__dirname
,../../
以及其他内容。
assets/scss/application.scss
看起来像这样:
$brand-primary: #306bb3 !default;
$brand-success: #ffb034 !default;
$gray-lighter: #e4e8ea !default;
$gray-lightest: #f5f5f5 !default;
$gray-dark: #555555 !default;
@import "bower_components/sass-mixins/mixins";
@import "bower_components/bootstrap/scss/bootstrap.scss";
@import "bower_components/font-awesome/scss/font-awesome";
@import "bower_components/fatcow-icons/flags-16px.css";
@import "bower_components/cookieconsent/build/cookieconsent.min.css";
@import "assets/scss/_partials/_layout";
我不知道为什么它在我的机器上完全正常但在Heroku上却没有...
答案 0 :(得分:1)
问题很可能是在部署期间未调用bower install