0

I am looking for a working recipe that can minify my AngularJS code and still provide a source map. Currently I have this gulp task but minification won't work:

gulp.task('browserify', function(cb) {
    var bundler = browserify({
            entries: [paths.browserEntry],
            globals: false,
            debug:   !settings.PRODUCTION
        })

    bundler
        .bundle()

        .on('error', cb)
        .on('log',   util.log)

        .pipe(gulpif(!settings.PRODUCTION, mold.transformSourcesRelativeTo(paths.js)))
        .pipe(source(paths.js))
        .pipe(buffer()) // because the next steps do not support streams
        .pipe(concat('bundle.js'))
        .pipe(gulpif(settings.server.minify.js, rename({suffix: '.min'})))
        .pipe(gulpif(settings.server.minify.js, uglify()))
        .pipe(gulp.dest(paths.js))
        .on('end', function() {
            cb()
        })
})

Any clues?

2
  • Will you like to see an example in grunt? :-) Commented Sep 7, 2014 at 4:40
  • Hmmm, okay. Might be helpful and give some hints. Thx Commented Sep 7, 2014 at 8:24

1 Answer 1

1

You may see an example here. The example will output a minified bundle.min.js plus a bundle.map. The crucial points which makes the example works:

  • Installed debowerify
  • Installed minifyify

package.json - added transform property

"browserify": {
    "transform": [
      "debowerify"
    ]
  }

Gruntfile.js - using preBundleCB to make minifyify work

  preBundleCB: function (b) {
    b.plugin( minifyify,
      { output: './dist/bundle.map',
        map:'bundle.map'
      });
  }

Hope the example is useful to you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.