我想看看这种文件夹结构:
assets
- scss
- folder
file.scss
anotherfile.scss
anotherfile.scss
anotherfile.scss
- anotherfolder
file.scss
anotherfile.scss
anotherfile.scss
anotherfile.scss
- css
main.css
.. 到 1 main.css。我使用 npm run scss + node-sass,从 package.json 文件中读取:
{
"name": "test",
"version": "1.0.0",
"description": " ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"scss": "node-sass --watch assets/sass/app.scss assets/css/app.css"
},
"license": "ISC",
"private": true,
"dependencies": {
"npm-sass": "^2.2.1"
}
}
当我更改子文件夹中的内容时,它会写入 main.css,但也会写入 CSS 文件,例如 css>folder>anotherfile.css。它给出了错误,因为当我更改 scss>folder>anotherfile.scss 时,编译器找不到变量,因为它似乎不知道我在 main.scss 中加载的 vars.scss 文件。
我不想这样。如何查看整个文件夹结构,但仅在发生更改时将 main.scss 编译为 main.css?提前致谢!
最佳答案
重命名除 main.scss
之外的所有文件,在名称前添加下划线,例如anotherfile.scss
=> _anotherfile.scss
关于css - SASS 观察器观察所有文件夹,编译为一个 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46829686/