我正在使用javascript渲染函数来自动化node-sass构建,但是import语句仍然无法找到波旁威士忌和整洁。
render.js
var sass = require('node-sass');
var bourbon = require("bourbon").includePaths;
var neat = require("bourbon-neat").includePaths;
var fs = require("fs");
var paths = bourbon.concat(neat)
console.log(paths)
fs.writeFile("/tmp/test", "Hey there!", function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
sass.render({
file: './app.scss',
includePaths: paths,
outFile: 'app.css',
sourceMap: true,
outputStyle: 'compressed'
}, function(error, result) { // node-style callback from v3.0.0 onwards
if (error) {
console.log(error.status); // used to be "code" in v2x and below
console.log(error.column);
console.log(error.message);
console.log(error.line);
}
else {
fs.writeFile("app.css", result.css.toString(), function (err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
fs.writeFile("app.css.map", result.map.toString(), function (err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
})
})
console.log(result.stats);
console.log(result.map.toString());
// or better
console.log(JSON.stringify(result.map)); // note, JSON.stringify accepts Buffer too
}
});
app.scss
@import "bourbon";
@import "neat";
@import 'base/index';
和控制台输出/错误:
c:\MedLever\MedLever\Styles>node render
[ 'c:\\MedLever\\MedLever\\Styles\\node_modules\\bourbon\\app\\assets\\stylesheets',
'c:\\MedLever\\MedLever\\Styles\\node_modules\\bourbon-neat\\app\\assets\\stylesheets' ]
{ Error: ENOENT: no such file or directory, open 'c:\tmp\test'
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'c:\\tmp\\test' }
1
13
no mixin named grid-media
Backtrace:
base/_header.scss:20
20
我错过了什么? includePaths应该告诉导入statemets在哪里看,但它似乎忽略了它。
答案 0 :(得分:0)
FFS - includePaths工作正常,Neat 2.0还没有在npm上。