使用GULP缩小HTML文件时出错

Error While Minified HTML File Using GULP

本文关键字:出错 文件 HTML GULP 缩小 使用      更新时间:2023-09-26

我是一名iOS开发者& &;目前我正试图缩小我所有的html文件。我用的是gulp &下面是我的gulpfile.js

var gulp = require('gulp');
var htmlmin = require('gulp-html-minifier');
gulp.task('minify', function() {
          gulp.src('./*.html')
          .pipe(htmlmin({collapseWhitespace: true}))
          .pipe(gulp.dest('./dist'))
          });

当我试图在终端上运行'gulp'时,我得到以下错误

Test2s-MacBook-Pro:TestFile test2$ gulp
[14:43:36] Using gulpfile ~/Desktop/TestFile/gulpfile.js
[14:43:36] **Task 'default' is not in your gulpfile**
[14:43:36] Please check the documentation for proper gulpfile formatting
Test2s-MacBook-Pro:TestFile test2$ 

谁能告诉我我做错了什么?我也看到了这个链接,但没有帮助https://github.com/gulpjs/gulp/issues/1155

请告诉我我做错了什么?

这是因为您没有提到gulp的默认任务尝试运行gulp minify命令而不是gulp

或使用

 gulp.task('default', ['minify']);