Grunt Uglify源地图“无法写入” [英] Grunt Uglify source map "unable to write"
问题描述
我使用Grunt来连接和缩小文件(使用grunt-contrib-uglify和grunt-contrib-concat),我想添加一个源映射。 uglify文档说只是为sourceMap设置一个选项为true的布尔值。但是,当我将它添加到我的任务(我尝试了几个不同的)时,该过程运行正常,直到它到达源映射部分,然后我得到:
写入true ... ERROR
警告:无法写入true文件(错误代码:undefined)。使用--force继续。
连接完成,缩小完成。但是... ...没有运气的源代码。
来自我的Grunt文件的示例:
uglify:{
选项:{
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%>']
}
}
}
(我也尝试过使用顶级选项对象中的sourceMap。) p>
有什么想法?显然Grunt可以写入目录,因为它创建了连接和缩小的文件,我想不出还有什么可能是麻烦。
div>https://github.com/gruntjs/grunt-contrib-uglify
从2.x迁移到3.x提到了这一点:
$ b
sourceMap - 只接受一个布尔值。生成一个包含
默认名称的地图
因此,看起来您正在使用旧版本的新版本配置选项。
- 您可以升级。
- 或使用旧版本的配置选项。 (我认为你应该把目标文件名赋值给这个变量而不是true,但是我没有在旧版本的文档中进行验证。)
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.)
这篇关于Grunt Uglify源地图“无法写入”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!