var gulp = require("gulp"); var rev = require("gulp-rev"); //用哈希码来修改引用文件名 var revReplace = require("gulp-rev-replace"); //更新引用文件名 var useref = require("gulp-useref"); //注释性文字来告诉gulp要怎样操作,一般是合并打包文件 var filter = require("gulp-filter"); //从水流中筛选出来一些水,处理完再放回水流中 var uglify = require("gulp-uglify"); //压缩js var csso = require("gulp-csso"); //压缩css gulp.task("default",function() { var jsFilter = filter("**/*.js",{restore:true}); var cssFilter = filter("**/*.css",{restore:true}); var indexHtmlFilter = filter(["**/*","!**/index.html"],{restore:true}); return gulp.src("src/index.html") .pipe(useref()) // .pipe(jsFilter()) // .pipe(uglify()) // Minify any javascript sources .pipe(jsFilter.restore) .pipe(cssFilter) .pipe(csso()) // Minify any CSS sources .pipe(cssFilter.restore) .pipe(indexHtmlFilter) .pipe(rev()) // Rename the concatenated files .pipe(indexHtmlFilter.restore) .pipe(revReplace()) // Substitute in new filenames .pipe(gulp.dest("dist")); }); ************************************************** 下面是修改的部分,修改完可以合并js,但是并没有压缩 return gulp.src("src/index.html") .pipe(useref()) // .pipe(jsFilter()) // .pipe(uglify()) // Minify any javascript sources .pipe(jsFilter.restore) .pipe(cssFilter) .pipe(csso()) // Minify any CSS sources .pipe(cssFilter.restore) .pipe(indexHtmlFilter) .pipe(rev()) // Rename the concatenated files .pipe(indexHtmlFilter.restore) .pipe(revReplace()) // Substitute in new filenames .pipe(gulp.dest("dist"));
如果不注释这两行,就会报错
// .pipe(jsFilter())
// .pipe(uglify())
TypeError: jsFilter is not a function
请问一下老师这是什么原因?