gpt4 book ai didi

javascript - 在 Gulp 中运行所有任务后,如何删除文件夹及其内容?

转载 作者:搜寻专家 更新时间:2023-10-31 23:35:27 24 4
gpt4 key购买 nike

这是我现在拥有的,但它不起作用。未清除 css 文件夹,但未抛出任何错误。

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var del = require('del');

gulp.task('default', ['compile-sass', 'process-css', 'clean-css']);

gulp.task('compile-sass', function () {
gulp.src('resources/assets/sass/main.scss')

// Compile Sass
.pipe(sass({
includePaths: ['resources/assets/bower/foundation/scss/foundation/components/']
}))

// Autoprefix CSS
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))

// Move to Temp Destination
.pipe(gulp.dest('resources/assets/css'));

});

gulp.task('process-css', ['compile-sass'], function () {
gulp.src(['resources/assets/css/main.css', 'bower/slick/slick/slick.css'])

// Concat CSS Files
.pipe(concat('all.min.css'))

// Minify CSS
.pipe(minifyCSS())

// Move to Final Destination
.pipe(gulp.dest('public/assets/css/'));

});

gulp.task('clean-css', ['process-css'], function () {

// Delete Temp Files & Folders
del(['resources/assets/css/']);

});

最佳答案

我想通了。我必须从之前的任务中返回流以确认它们已完成。

var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var del = require('del');

gulp.task('default', ['compile-sass', 'process-css', 'clean-css']);

gulp.task('compile-sass', function () {
var stream = gulp.src('resources/assets/sass/main.scss')

// Compile Sass
.pipe(sass({
includePaths: ['resources/assets/bower/foundation/scss/foundation/components/']
}))

// Autoprefix CSS
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))

// Move to Temp Destination
.pipe(gulp.dest('resources/assets/css'));

return stream;

});

gulp.task('process-css', ['compile-sass'], function () {
var stream = gulp.src(['resources/assets/css/main.css', 'bower/slick/slick/slick.css'])

// Concat CSS Files
.pipe(concat('all.min.css'))

// Minify CSS
.pipe(minifyCSS())

// Move to Final Destination
.pipe(gulp.dest('public/assets/css/'));

return stream;

});

gulp.task('clean-css', ['process-css'], function () {

// Delete Temp Files & Folders
del(['resources/assets/css/']);

});

关于javascript - 在 Gulp 中运行所有任务后,如何删除文件夹及其内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28648312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com