【问题标题】:includePaths isn't providing my import statement with what I need in node-sassincludePaths 没有为我的 import 语句提供我在 node-sass 中需要的东西
【发布时间】:2018-04-21 15:12:19
【问题描述】:

我正在使用 javascript 渲染函数来自动化 node-sass 构建,但导入语句仍然无法找到波旁威士忌和整洁。

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 应该告诉 import statemetns 在哪里看,但它似乎忽略了它。

【问题讨论】:

    标签: bourbon node-sass neat


    【解决方案1】:

    FFS -- includePaths 工作正常,Neat 2.0 还没有在 npm 上。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-03
      • 2016-10-19
      • 1970-01-01
      • 2021-11-25
      • 1970-01-01
      • 2013-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多