【发布时间】: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