Hi I am making a theme for the company i work at and the JS segments will not build properly in uglify. I am trying to use uglify to simply concatenate my files, which works but they output minified and mangled with no comments and i cannot figure out why, below is my gulp task which runs correctly but doesnt output with the options provided
gulp.task('js', function() {
return gulp.src('./src/js/*.js')
    .pipe(uglify({
        options: {
            mangle: false,
            beautify: true,
            comments: true
        }
    }))
    .pipe(rename('cf247bootstrapTheme.js'))
    .pipe(gulp.dest('./dist/js'));
});
Any ideas why this is happening?
Thanks,
Kieran
Probably options are not passed as expected.
Try this for uglify pipe:
.pipe(uglify({
    mangle: false,
    output: {
        beautify: true,
        comments: true
    }
})
                        The options are available in the UglifyJS readme.
Example config to match what's in the question (+console):
.pipe(uglify({
    // https://github.com/mishoo/UglifyJS#mangle-options
    mangle: {
        toplevel: false
    },
    // https://github.com/mishoo/UglifyJS#compress-options
    compress: {
        drop_console: false
    },
    // https://github.com/mishoo/UglifyJS#output-options
    output: {
        beautify: true,
        comments: true,
        preamble: "/* Licensing info */"
    }
}))
For a production build you might want to consider using:
.pipe(uglify({
    // https://github.com/mishoo/UglifyJS#mangle-options
    mangle: {
        toplevel: true
    },
    // https://github.com/mishoo/UglifyJS#compress-options
    compress: {
        drop_console: true
    },
    // https://github.com/mishoo/UglifyJS#output-options
    output: {
        beautify: false,
        comments: false,
        preamble: "/* Licensing info */"
    }
}))
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With