2

Problem

Breakpoints not breaking in browser from source-maps generated using grunt task of yeoman-angular-generator. The code has been concatenated and minified.

What I have tried

I have looked at this Stack Overflow answer for the configuration of the grunt task and have generated what I think is the correct source-map using the following grunt config:

concat : {
  options : {
    sourceMap :true
  }
},
uglify: {
  options: {
    sourceMap: true,
    sourceMapIncludeSources : true,
    sourceMapIn : '.tmp/concat/scripts/scripts.js.map'
  }
},

What I need help with

Has anyone used the yeoman-angular-generator and managed to concat then minify their code and generate source-maps from it? What steps are needed to make it work?

I need to concat and minify my code. Getting source-maps to work with JUST minification is easy or JUST concatenation is also easy but with BOTH concat and minify it seems to not work so well.

Is there a solution to this?

Community
  • 1
  • 1
Subtubes
  • 12,859
  • 21
  • 59
  • 90

1 Answers1

0

I was able to do this, changing the usemin configuration and adding some properties to the concat/uglify configuration object. But attention, the dist files produced by this options are not good for production!

useminPrepare: {
  html: '<%= yeoman.app %>/index.html',
  options: {
    dest: '<%= yeoman.dist %>',
    flow: {
      html: {
        steps: {
          js: ['concat', 'uglifyjs'],
          css: ['cssmin']
        },
        post: {
          js: [{
            name: 'uglify',
            createConfig: function (context, block) {
              var generated = context.options.generated;
              generated.options = {
                stripBanners: true,
                mangle: false,
                sourceMap: true,
                sourceMapIncludeSources: true,
                compress: false,
                beautify: true
              };
            }
          },
          {
            name: 'concat',
            createConfig: function (context, block) {
              var generated = context.options.generated;
              generated.options = {
                //stripBanners: true,
                //mangle: false,
                sourceMap: true,
                sourceMapIncludeSources: true,
                separator: ';',
              };
            }
          }]
        }
      }
    }
  }
}
FAvIo41
  • 271
  • 1
  • 3
  • 11
  • This doesn´t really helps. The extra config don´t minify the scripts. Why would you need sourcemaps for non minified code in the first place? – darksoulsong Dec 09 '15 at 11:19