【问题标题】:Why is the --output option ignored in node-sass?为什么 node-sass 中忽略了 --output 选项?
【发布时间】:2020-08-08 21:36:10
【问题描述】:

我尝试使用具有以下目录配置的 npm 脚本编译 SASS。

project
├ page1
│ └ style
│   ├ sass
│   │ └ *.scss
│   └ css
├ page2
│ └ style
│   ├ sass
│   │ └ *.scss
│   └ css
├ ...
├ pageN
│ └ style
│   ├ sass
│   │ └ *.scss
│   └ css
└ package.json

所以我考虑使用 glob 和 node-sass 的 --output 选项。

{
  "name": "sass",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "sass": "node-sass ./**/style/sass/ --output ./**/style/css/"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "node-sass": "^4.14.0"
  }
}

但这并没有在 CSS 目录中生成 CSS 文件。

相反,SASS 目录中有一个 CSS 文件。这意味着指定输出目录的--output 选项将被忽略。

如何使用 npm 脚本将它们编译到 css 目录中?

$ npm run sass

> sass@1.0.0 sass C:\Users\sanriot\Desktop\project
> node-sass ./**/assets/sass/ --output ./**/assets/css/

Rendering Complete, saving .css file...
Wrote CSS to C:\Users\sanriot\Desktop\project\page1\style\sass\style.css
Rendering Complete, saving .css file...
Wrote CSS to C:\Users\sanriot\Desktop\project\page2\style\sass\style.css
Rendering Complete, saving .css file...
Wrote CSS to C:\Users\sanriot\Desktop\project\page3\style\sass\style.css
Wrote 3 CSS files to C:\Users\sanriot\Desktop\project\**\style\css\

【问题讨论】:

    标签: javascript node.js sass npm-scripts node-sass


    【解决方案1】:

    选项需要在输入https://github.com/sass/node-sass#usage-1node-sass [options] <input> [output]之前。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-28
      • 2014-12-27
      • 1970-01-01
      • 2022-12-23
      • 2019-05-15
      • 2012-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多