Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to use sourcemaps and minification of files? #99

Open
davidrhoderick opened this issue Apr 16, 2020 · 0 comments
Open

Any way to use sourcemaps and minification of files? #99

davidrhoderick opened this issue Apr 16, 2020 · 0 comments

Comments

@davidrhoderick
Copy link

Looks like as per issues #9 and #49, sourcemaps work if there is no minification. That's great and all but sourcemaps are way more useful when minification is happening and I can see very few use-cases where minification isn't used in production deployment. However, I've tried gulp-uglify and gulp-minify with gulp-sourcemaps and gulp-include and can only get the sourcemaps to work when I skip minification. Here's my current environment:

{
  "dependencies": {
    "browser-sync": "^2.26.3",
    "gulp": "^3.9.1",
    "gulp-include": "^2.3.1",
    "gulp-jshint": "^2.1.0",
    "gulp-minify": "^3.1.0",
    "gulp-notify": "^3.2.0",
    "gulp-plumber": "^1.2.0",
    "gulp-sass": "^4.0.1",
    "gulp-sass-lint": "^1.4.0",
    "gulp-sourcemaps": "^2.6.5",
    "jshint": "^2.9.6",
    "gulp-uglify": "^3.0.2"
  }
}

And I'm on Node 11.15.0. My task looks like the following:

gulp.task('js', function(){
  return gulp.src('static/js/site.js')
    .pipe(sourcemaps.init())
    .pipe(include())
      .on('error', notify)
    .pipe(jshint.reporter('default'))
    .pipe(minify({
      noSource: true,
      ext:{
        src: '.js',
        min: '.min.js'
      }
    }))
    .pipe(sourcemaps.write('./'))
    .pipe(gulp.dest('static'))
    .pipe(browserSync.stream());
});

That's with gulp-minify, which I'd ideally like to use, but even when I remove that .pipe(minify({...}) block and put in .pipe(uglify()), I still don't get a proper sourcemap. I can see that it's trying because it says that my test file, which is at the end of including jQuery, is part of jQuery only at the end of the file. If I even just include the site.js instead of site.min.js, it's correct. Does anyone have a working method for using sourcemaps with include and minification?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant