0
我想要的是來縮小我在我的index.html所有的JS然後刪除所有console.logs如何運行使用一飲而盡
我嘗試了兩種選擇醜化然後帶調試在一個任務:
我試圖MERGE但只有醜化執行
// Command: gulp useref
gulp.task('useref', function(){
var _uglify = gulp.src('app/index.html') // .src is the function that is very similar to locating or searching on that file or folder
.pipe(useref())
// Minifies only if it's a Javascript file
.pipe(gulpIf('*.js', uglify()))
// Minifies only if it's a CSS file
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('app/')) // .dest is the location where it will produce the output
// set to app/, so it will automatically change the index and there's no need to move files
var _strip_debug = gulp.src('app/assets/js/scripts.js')
.pipe(stripDebug())
.pipe(gulp.dest('app/assets/js'));
return merge(_uglify, _strip_debug);
});
我試圖返回兩個,而是隻執行醜化:
gulp.task('useref', function(){
return gulp.src('app/index.html') // .src is the function that is very similar to locating or searching on that file or folder
.pipe(useref())
// Minifies only if it's a Javascript file
.pipe(gulpIf('*.js', uglify()))
// Minifies only if it's a CSS file
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('app/')) // .dest is the location where it will produce the output
// set to app/, so it will automatically change the index and there's no need to move files
return gulp.src('app/assets/js/scripts.js')
.pipe(stripDebug())
.pipe(gulp.dest('app/assets/js'));
});
您的變量的名字是'_uglify'但你通過'uglify'成'合併()'?改變它能解決什麼問題嗎? –
我改變了它,錯誤消失了。但是,控制檯日誌不會被刪除 –