I use the "gulp-babel" before uglifying my js files. The module blocks the minification because a third party js script is not "strict mode" compilant.
// Include gulp
var gulp = require('gulp');
var baseDir = "./";
var jsources = [
"sites/**/js/*.js",
"!sites/**/js/*.min.js"
];
// Include Plugins
var jshint = require('gulp-jshint');
var babel = require('gulp-babel');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
// Minify JS
gulp.task('scripts', function () {
return gulp.src(jsources, { base: baseDir })
.pipe(babel({
presets: [
['env', { modules: false }]
]
}))
.pipe(uglify().on('error', function (e) { console.log(e); }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(baseDir));
});
As result I obtain an error because a js file is not strict mode compilant:
I don't want to modify that third-party file to make it strict mode compilant. How can I disable that check for that file or another similar files?
Just now the minification is blocked because of that kind of files...
I tried
to install the "transform-remove-strict-mode" plugin and then do
.pipe(babel({ "presets": ["env"], "plugins": ["transform-remove-strict-mode"] }))
I also tried the
.pipe(babel({ presets: [ ["es2015", { "modules": false }] ] }))
but the output is still the same...