简体   繁体   English

Gulp Sass使用过滤器将同一文件夹中的所有文件

[英]Gulp Sass All Files in Same Folder with Filter

I'm trying to run Gulp Sass for all of my files in a folder and its subfolders and keep the css results at the path where the scss file is. 我正在尝试为文件夹及其子文件夹中的所有文件运行Gulp Sass,并将css结果保留在scss文件所在的路径中。

When I run this 当我运行这个

var filter = filters(['*', '!app/css/skins/color-vars-template.scss',     '!app/css/skins/skin-template.scss']);
gulp.task('sass', function () {
    gulp.src('app/css/*.scss')
        .pipe(filter)
        .pipe(sass())
        .pipe(gulp.dest("app/css"))

});

I have the css compiled files in the app/css folder. 我在app / css文件夹中有CSS编译文件。

之前

后

Now when I run this 现在当我运行这个

var filter = filters(['*', '!app/css/skins/color-vars-template.scss',     '!app/css/skins/skin-template.scss']);
gulp.task('sass', function () {
    gulp.src('app/**/*.scss')
        .pipe(filter)
        .pipe(sass())
        .pipe(gulp.dest("app/**/*"))

});

I want to compile all of the scss files and keep the css files in the folder where the scss file is however nothing happens. 我想编译所有的scss文件,并将css文件保存在scss文件所在的文件夹中,但是什么也没发生。

CSS文件没有出现

It looks like you could just simplify your gulp.dest to get file path you want. 看来您可以简化gulp.dest以获得所需的文件路径。

  • change: .pipe(gulp.dest("app/**/*")) 更改: .pipe(gulp.dest("app/**/*"))
  • to: .pipe(gulp.dest("app")) 到: .pipe(gulp.dest("app"))

Explained here: https://stackoverflow.com/a/23249384/284091 在这里解释: https : //stackoverflow.com/a/23249384/284091

The destination doesn't need to be dynamic as the globbed path is used for the dest as well. 目的地不需要是动态的,因为目的地也使用了球形路径。 Simply pipe to the same base directory you're globbing the src from, in this case "app". 只需通过管道将其传递到您要在其中分发src的同一基本目录,本例中为“ app”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM