【问题标题】:SASS watcher to watch all folders, compile to one CSSSASS watcher 监视所有文件夹,编译成一个 CSS
【发布时间】:2018-03-31 11:30:06
【问题描述】:

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

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?提前致谢!

【问题讨论】:

标签: css npm sass watch


【解决方案1】:

重命名除main.scss 之外的所有文件,使其名称前有下划线,例如anotherfile.scss => _anotherfile.scss

【讨论】:

    猜你喜欢
    • 2014-04-28
    • 1970-01-01
    • 2020-07-08
    • 2013-11-10
    • 2020-07-08
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多