css - SASS 观察器观察所有文件夹,编译为一个 CSS

标签 css npm sass watch

我想看看这种文件夹结构:

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/

相关文章:

html - 禁用单个样式的 CSS 转换?

node.js - 尝试使用 NPM 安装任何内容时出现 ECONNREFUSED

html - 最大高度等于最大宽度

twitter-bootstrap - 错误 "Compass can' t 找不到要编译的任何 Sass 文件。”在 compass 创建

html - 使 flex 元素换行以形成 2 列网格

html - 标题中的响应链接

html - z-index 在我的菜单上不起作用

node.js - { [错误 : Command failed: ] killed: false, 代码 : 1, 信号:空 }

gruntjs - 是否有像 grunt-wiredep 这样的注入(inject)器适用于 NPM 依赖项?

css - 将 Compass 实现到现有的 Sass 元素中