【问题标题】:SASS watch multiple .scss in sub-dir of directory select?SASS在目录选择的子目录中监视多个.scss?
【发布时间】:2018-11-15 00:27:04
【问题描述】:

我开始了一个项目,我有这个:Site

我喜欢做这样的事情:

: sass --watch 组件/*.scss:css/style.css

当在 Component/ 中的任何 .scss 中完成保存时,它会运行“watch”,这可能吗?

感谢寻找;

【问题讨论】:

    标签: sass watch


    【解决方案1】:

    如果您使用的是 sass gem,您有以下选择:

    update 将编译文件夹中的单个文件或多个文件(取决于参数)。 watch 会做同样的事情,在初始编译完成后,它将监视指定文件夹中的文件或所有文件,因此每次检测到任何目标文件发生更改时,sass 将编译更改的文件。

    两个选项具有相同的命令行语法:

    sass --watch input/folder:output/folder
    sass --watch input.scss:output.css
    

    所以,编译一个文件夹中的所有文件:

    sass --update path/to/input/folder:path/to/output/folder
    

    然后编译然后监视一个文件夹:

    sass --watch path/to/input/folder:path/to/output/folder
    

    只需运行 sass --help 即可获得完整的选项列表。

    希望对你有帮助!

    【讨论】:

      【解决方案2】:

      假设,您使用 gulp 运行任务。

      var sass = require('gulp-sass'); //after npm i gulp-sass --save-dev in your terminal.
      
      gulp.task('watch', function(){
        gulp.watch('./app/sass/*.scss', ['sass']);  //place the correct location of your scss folder
      });
      

      并在“构建”任务中包含监视

      // *** build task *** //
      gulp.task('build', function() {
        runSequence(
          ['watch']
        );
      });
      

      希望这会有所帮助!

      【讨论】:

      • 我使用 gem 代替 gulp,所以我希望 hack 也可以使用它。非常感谢您的回答。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      • 2017-02-14
      • 1970-01-01
      • 1970-01-01
      • 2014-12-08
      • 2012-05-29
      • 2013-02-19
      相关资源
      最近更新 更多