我有一个包含空传播运算符的 JS 表达式,但是在应用 gulp 作业来缩小 JS 时失败。有谁知道如何保持这种语法(不做 if/else 或使用三元运算符(表达式?真:假)?
我的表情
let tableTitle = $(config.$table[0])?.siblings('.title-section')[0]?.innerText;
吞咽错误:
TypeError in plugin "gulp-minify"
Message: dev\js\app_delivery.js
Cannot read property 'replace' of undefined (line: undefined, col: undefined, pos: undefined
Details:
domainEmitter: [object Object]
domain: [object Object]
domainThrown: false
我的 gulp 任务导致错误:
gulp.task('JS-libs', function() {
return gulp.src(config.modules.JS.libs)
.pipe(concat('libs.js'))
.pipe(minifyJS())
.pipe(gulp.dest(config.path.dest.rootJS))
});
minifyJS 函数:
function minifyJS() {
return gulpMinifyJS({
ext:{
src: '.js',
min:'.min.js'
}
});
}
还有我关于 gulp 的 package.json 配置:
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-concat": "^2.6.1",
"gulp-cssmin": "^0.2.0",
"gulp-minify": "^3.1.0",
"gulp-remove-logging": "^1.2.0",
"gulp-rename": "^1.4.0",
"gulp-replace": "^1.0.0",
"uglifyjs": "^2.4.11"
在此先感谢您的帮助