具有值“ sass('floder1')”的Gulp函数]]

问题描述 投票:1回答:1

我正在尝试将相同的gulpfile.js用于多个项目。假设我要对两个不同的项目使用相同的sass()函数。我尝试传递像javascript sass(x){.... .src(x+"/src/style/scss/*.scss")}这样的值。但是它没有用。有没有为多个项目使用相同的gulpfile.js的示例?

function css(x) {
  return gulp
    .src(x+"/src/style/scss/*.scss")
    .pipe(plumber())
    .pipe(sass({
      outputStyle: "expanded"
    }))
    .pipe(autoprefixer())
    .pipe(gulp.dest(x+"/src/style/css"))
    .pipe(cleanCSS({
      compatibility: 'ie8'
    }))
    .pipe(rename({
      suffix: '.min'
    }))
    .pipe(gulp.dest(x+'/src/min/css'))
    .pipe(gulp.dest(x+'/dist/css'));
}

function watch(x){
   gulp.watch(x+'/src/style/scss/**', css(x));
   gulp.watch(x+'/src/js/**', js(x));
   gulp.watch(x+'/dist/**', deploy(x));
}

以类似gulp watch("folder1")的命令运行

它什么也没做。或者,它没有监视任何文件夹并没有运行任何任务。

我正在尝试将相同的gulpfile.js用于多个项目。假设我要对两个不同的项目使用相同的sass()函数。我尝试过传递值,例如javascript sass(x){.... .src(x +“ / src / ...

gulp gulp-watch gulp-4
1个回答
0
投票

您可以为此使用yargs软件包

© www.soinside.com 2019 - 2024. All rights reserved.