terinjokes/gulp-uglify

SourceMap not working well with gulp-uglify

HACHIMIam opened this issue · 0 comments

Describe the bug
SourceMaps doesn't work as expected with gulp-uglify and works very well when i dont use gulp-uglify the
To Reproduce

Minimal code to reproduce the bug
this is the sourceMap config

const gulp = require('gulp');
const paths = require('./../lib/paths');
const gulpif = require('gulp-if');
const changed = require('gulp-changed');
const plumber = require('gulp-plumber');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
        


gulp.task('es6', () => {
    const babel = require('gulp-babel');
    const config = require('./../lib/config');
    const babelConfiguration = require('./../configuration/babel.config');

    const scripts = paths.getAppPaths();
    return gulp.src([
        ...scripts.sources,
    ], { base: scripts.root })
        .pipe(gulpif(config.global.sourceMaps, sourcemaps.init()))
        .pipe(plumber())
        .pipe(changed(scripts.dist, { extension: '.js' }))
        .pipe(babel(babelConfiguration))
        //.pipe(uglify()) sourceMaps works when i comment this line and doesn't work when i uncomment 
       //it 
        .pipe(gulpif(config.global.sourceMaps, sourcemaps.write('.')))
        .pipe(gulp.dest(scripts.dist));
});

the configuration/babel.config is this

const config = require('./../lib/config');
const babelEnv = require('@babel/preset-env');
const babelSystemJS = require('@babel/plugin-transform-modules-systemjs');
const path = require('path');

const babelPlugins = [];

if (config.global.jspm) {
    babelPlugins.push([babelSystemJS]);
}

const presets = [
    [babelEnv, {
        // "useBuiltIns": "entry",
        // "targets": browsersList,
    }],
];




module.exports = {
    babelrc: false,
    plugins: babelPlugins,
    cwd: path.dirname(__dirname),
    presets,
    moduleIds: false,
    comments: false,
};

Actual Output

when i uncomment the pipe((uglify)) line i get this with gulp-uglify
Screenshot 2019-07-18 at 09 21 23

Expected Output

when i comment the pipe((uglify)) line without gulp-uglify

Screenshot 2019-07-18 at 09 48 33

Configuration

i m using gulp-uglify version ^3.0.1 in babelrc and gulp-sourcemaps: ^2.6.4,