I'm using Grunt to concat and minify files (with grunt-contrib-uglify and grunt-contrib-concat ) and I wanted to add a source map. The uglify docs say to just add an option for sourceMap set to a boolean of true. But when I add that to my tasks (I've tried a couple different ones) the process runs fine until it gets to the source map part, then I get:
Writing true...ERROR
Warning: Unable to write "true" file (Error code: undefined). Use --force to continue.
The concatenation is done, the minification is done. But... no luck with the sourcemap.
Sample from my Grunt file:
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
},
publicjs: {
options: {
sourceMap: true
},
files: {
'js/<%= pkg.name %>_public.min.js': ['<%= concat.publicjs.dest %>']
}
}
}
(I've also tried with the sourceMap in my top level options object.)
Any ideas? Clearly Grunt can write to the directory because it creates the concatenated and minified files, and I can't think of what else might be the trouble.
https://github.com/gruntjs/grunt-contrib-uglify
Section " Migrating from 2.x to 3.x" mentions this:
sourceMap - Only accepts a Boolean value. Generates a map with a default name for you
So it looks like you are using an older version with the new version's config options.
- You can upgrade.
- Or use the older version's config options. (I think you should assign the destination file name to this variable instead of true. But I didn't verify in the old version's documentation.)
来源:https://stackoverflow.com/questions/22570331/grunt-uglify-source-map-unable-to-write