Grunt Uglify source map “unable to write”

我的梦境 提交于 2019-12-07 08:20:15

问题


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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!