<i id='fP358'><tr id='fP358'><dt id='fP358'><q id='fP358'><span id='fP358'><b id='fP358'><form id='fP358'><ins id='fP358'></ins><ul id='fP358'></ul><sub id='fP358'></sub></form><legend id='fP358'></legend><bdo id='fP358'><pre id='fP358'><center id='fP358'></center></pre></bdo></b><th id='fP358'></th></span></q></dt></tr></i><div id='fP358'><tfoot id='fP358'></tfoot><dl id='fP358'><fieldset id='fP358'></fieldset></dl></div>
      1. <small id='fP358'></small><noframes id='fP358'>

        <legend id='fP358'><style id='fP358'><dir id='fP358'><q id='fP358'></q></dir></style></legend>
      2. <tfoot id='fP358'></tfoot>
        • <bdo id='fP358'></bdo><ul id='fP358'></ul>
      3. Gulp less 然后缩小任务

        时间:2023-05-28

          <tbody id='zJYKt'></tbody>
          <bdo id='zJYKt'></bdo><ul id='zJYKt'></ul>

          1. <tfoot id='zJYKt'></tfoot>
          2. <small id='zJYKt'></small><noframes id='zJYKt'>

                <legend id='zJYKt'><style id='zJYKt'><dir id='zJYKt'><q id='zJYKt'></q></dir></style></legend>
                • <i id='zJYKt'><tr id='zJYKt'><dt id='zJYKt'><q id='zJYKt'><span id='zJYKt'><b id='zJYKt'><form id='zJYKt'><ins id='zJYKt'></ins><ul id='zJYKt'></ul><sub id='zJYKt'></sub></form><legend id='zJYKt'></legend><bdo id='zJYKt'><pre id='zJYKt'><center id='zJYKt'></center></pre></bdo></b><th id='zJYKt'></th></span></q></dt></tr></i><div id='zJYKt'><tfoot id='zJYKt'></tfoot><dl id='zJYKt'><fieldset id='zJYKt'></fieldset></dl></div>

                  本文介绍了Gulp less 然后缩小任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我必须在 gulp 中执行 2 个步骤:

                  I have to make 2 steps in gulp:

                  1. 减少 .css 文件格式
                  2. 缩小生成的 css 文件

                  这是我的 gulpfile:

                  This is my gulpfile:

                  var gulp = require('gulp'),
                      watch = require("gulp-watch"),
                      less = require('gulp-less'),
                      cssmin = require('gulp-cssmin'),
                      rename = require('gulp-rename');
                  
                  gulp.task('watch-less', function () {
                      watch({glob: './*.less'}, function (files) { // watch any changes on coffee files
                          gulp.start('compile-less'); // run the compile task
                      });
                  
                      watch({
                          glob: ['./*.css', '!./*.min.css']
                      }, function(files) {
                          gulp.start('minify-css'); // run the compile task
                      });
                  });
                  
                  gulp.task('compile-less', function () {
                      gulp.src('./*.less') // path to your file
                      .pipe(less().on('error', function(err) {
                          console.log(err);
                      }))
                      .pipe(gulp.dest('./'));
                  });
                  
                  gulp.task('minify-css', function() {
                      gulp.src([
                          './*.css',
                          '!./*.min.css'
                      ])
                      .pipe(cssmin().on('error', function(err) {
                          console.log(err);
                      }))
                      .pipe(rename({suffix: '.min'}))
                      .pipe(gulp.dest('./'));
                  })
                  
                  gulp.task('default', ['watch-less']);
                  

                  当我启动它时,只完成了第一步.请帮帮我.

                  When i start it only first step is done. Help me please.

                  推荐答案

                  时间久了就不需要了,对我来说方便的解决方案是:

                  There is no needing after time, convinient solution for me was:

                  var gulp = require('gulp'),
                      less = require('gulp-less'),
                      cssmin = require('gulp-cssmin'),
                      plumber = require('gulp-plumber'),
                      rename = require('gulp-rename');
                  
                  gulp.task('watch', function () {
                      gulp.watch('./styles/*.less', ['less']);
                  });
                  
                  gulp.task('less', function () {
                      gulp.src('./styles/*.less')
                          .pipe(plumber())
                          .pipe(less())
                          .pipe(gulp.dest('./styles/'))
                          .pipe(cssmin())
                          .pipe(rename({
                              suffix: '.min'
                          }))
                          .pipe(gulp.dest('./styles'))
                  
                  });
                  
                  gulp.task('default', ['less', 'watch']);
                  

                  这篇关于Gulp less 然后缩小任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如果满足条件,则停止 Gulp 任务 下一篇:gulp.dest 没有创建目标文件夹

                  相关文章

                  最新文章

                    1. <tfoot id='ZU3Xe'></tfoot>
                      • <bdo id='ZU3Xe'></bdo><ul id='ZU3Xe'></ul>

                    2. <legend id='ZU3Xe'><style id='ZU3Xe'><dir id='ZU3Xe'><q id='ZU3Xe'></q></dir></style></legend>
                    3. <small id='ZU3Xe'></small><noframes id='ZU3Xe'>

                      <i id='ZU3Xe'><tr id='ZU3Xe'><dt id='ZU3Xe'><q id='ZU3Xe'><span id='ZU3Xe'><b id='ZU3Xe'><form id='ZU3Xe'><ins id='ZU3Xe'></ins><ul id='ZU3Xe'></ul><sub id='ZU3Xe'></sub></form><legend id='ZU3Xe'></legend><bdo id='ZU3Xe'><pre id='ZU3Xe'><center id='ZU3Xe'></center></pre></bdo></b><th id='ZU3Xe'></th></span></q></dt></tr></i><div id='ZU3Xe'><tfoot id='ZU3Xe'></tfoot><dl id='ZU3Xe'><fieldset id='ZU3Xe'></fieldset></dl></div>