angularjs - Getting sourcemaps to work with Grunt, usemin, uglify and rev -


i'm using grunt optimize angularjs application production. uses useminprepare , usemin read files concat/minify index.html page. i'm trying sourcemaps work can view errors happening. here's relevant versions package.json:

"grunt": "0.4.5", "grunt-autoprefixer": "2.2.0", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-cssmin": "~0.11.0", "grunt-contrib-uglify": "~0.9.1", "grunt-rev": "~0.1.0", "grunt-usemin": "~2.0.2", 

here's trimmed down version of gruntfile.js relevant tasks:

'use strict';  // usemin custom step var useminautoprefixer = {     name: 'autoprefixer',     createconfig: require('grunt-usemin/lib/config/cssmin').createconfig // reuse cssmins createconfig };  module.exports = function (grunt) {     require('load-grunt-tasks')(grunt);      grunt.initconfig({         pkg: grunt.file.readjson('package.json'),         clean: ["dist", '.tmp'],         copy: {             main: {                 files: [                     {                         expand: true,                         src: ['**', '!css/**', '!*.js', '!node_modules/**', '!*.log', '!tests/**'],                         dest: 'dist/'                     }                 ]             }         },         cssmin: {             options: {                 root: './' // replace relative paths static resources absolute path             }         },         rev: {             files: {                 src: ['dist/assets/**/*.{js,css}']             }         },         useminprepare: {             html: 'index.html',             options: {                 flow: {                     html: {                         steps: {                             js: ['concat', 'uglifyjs'],                             css: ['cssmin', useminautoprefixer] // let cssmin concat files corrects relative paths fonts , images                         },                         post: {                             js: [{                                 name: 'concat',                                 createconfig: function (context, block) {                                     context.options.generated.options = {                                         sourcemap: true                                     };                                 }                             }, {                                 name: 'uglifyjs',                                 createconfig: function (context, block) {                                     context.options.generated.options = {                                         sourcemapin: '.tmp/concat/' + block.dest.replace('.js', '.js.map'),                                         mangle: false,                                         beautify: {                                             beautify: true                                         }                                     };                                 }                             }]                         }                     }                 }             }         },         usemin: {             html: ['dist/index.html']         },         uglify: {             options: {                 report: 'min',                 mangle: false             },             generated: {                 options: {                     sourcemap: true                 }             }         }     });      grunt.registertask('build', [         'clean', 'useminprepare', 'concat', 'copy', 'cssmin', 'autoprefixer', 'uglify', 'rev', 'usemin'     ]); }; 

the *.js.map files being generated in dist/assets/js. , revved js files seem reference them fine:

//# sourcemappingurl=app.js.map 

however, looking in sourcemap, seems might have bad directory path , filename:

{"version":3,"file":"app.js","sources":["../../../.tmp/concat/assets/js/app.js"] ... 

any idea how make sourcemaps work grunt, usemin, uglify, , rev?


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -