問題描述
我正在嘗試縮小我正在使用 gulp 任務(wù)運(yùn)行程序的腳本文件我正在嘗試 gulp-uglify 插件
I am trying to minify my script files for which i am using gulp task runner And I am trying gulp-uglify plugin
代碼:
gulp.task('concat', function() {
return gulp.src('app/**/*.js')
// .pipe(concat('script.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist/'))
});
但我收到錯誤
當(dāng)我嘗試將 gulp 任務(wù)作為 gulp concat 運(yùn)行時(shí)任何幫助將不勝感激
when i try to run gulp task as gulp concat Any help would be appreciated
推薦答案
主要錯誤是在使用 ES6 格式時(shí)產(chǎn)生的.使用 gulp-uglify-es 模塊而不是 'gulp-uglify' 來克服這個(gè)錯誤.
The main error is generated when you're using ES6 format. Use the gulp-uglify-es module instead of 'gulp-uglify' to overcome this error.
var uglify = require('gulp-uglify-es').default;
注意:gulp-uglify-es 不再維護(hù).您可能想使用 terser
/gulp-terser
代替:
Note: gulp-uglify-es is no longer being maintained. You may want to use terser
/gulp-terser
instead:
這篇關(guān)于GulpUglifyError:無法縮小 JavaScript的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!