这里也有个问题:http://stackoverflow.com/questions/14207983/how-to-specify-multiple-source-maps-in-uglify-grunt-task
参考了这里 http://flippinawesome.org/2013/07/01/building-a-javascript-library-with-grunt-js/
module.exports = function(grunt) {
var bannerContent = '... banner template ...';
var name = '<%= pkg.name %>-v<%= pkg.version%>';
grunt.initConfig({
// pkg must be defined inside initConfig object
pkg : grunt.file.readJSON('package.json'),
// uglify configuration
uglify: {
options: {
banner: bannerContent,
sourceMapRoot: '../',
sourceMap: 'distrib/'+name+'.min.js.map',
sourceMapUrl: name+'.min.js.map'
},
target : {
src : ['src/**/*.js'],
dest : 'distrib/' + name + '.min.js'
}
},
concat: { /* ... concat configuration ... */ },
jshint: { /* ... jshint configuration ... */ }
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['jshint', 'concat', 'uglify']);
};
我的配置
uglify : {
options : {
banner:'/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
sourceMapRoot: '../',
sourceMap:'dist/' + '.map',
sourceMapUrl: '.min.js.map'
},
main:{
files: [
{
expand: true,
cwd: 'dist/',
src: ['js/**/*.js', '!js/**/*-debug.js'],
dest: 'dist/'
}
]
}
}
最后只生成了一个 .min.js.map,只是对一个js的map,没达到目录下所有的js的source-map效果
参考上面 http://stackoverflow.com/a/17503492
解决