includePaths 没有提供我在 node-sass 中需要的导入语句
includePaths isn't providing my import statement with what I need in node-sass
我正在使用 javascript 渲染函数来自动执行 node-sass 构建,但导入语句仍然无法找到 bourbon 和 neat。
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';
和控制台 output/error:
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 应该告诉 import statemetns 去哪里找,但它似乎忽略了它。
FFS -- includePaths 工作正常,Neat 2.0 尚未在 npm 上。
我正在使用 javascript 渲染函数来自动执行 node-sass 构建,但导入语句仍然无法找到 bourbon 和 neat。
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';
和控制台 output/error:
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 应该告诉 import statemetns 去哪里找,但它似乎忽略了它。
FFS -- includePaths 工作正常,Neat 2.0 尚未在 npm 上。