如何在uglify grunt任务中指定多个源图? [英] How to specify multiple source-maps in uglify grunt task?

查看:146
本文介绍了如何在uglify grunt任务中指定多个源图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 grunt 0.4 中使用 grunt-contrib-uglify 插件。

我有以下任务:

I have the following task:

uglify: {
  dist: {
    options: {
      sourceMap: 'dist/sm/sm.js'
    },
    files: grunt.file.expandMapping(['*.js'], 'dist/js', {
      cwd: 'dist/js'
    })
  }
},

正如您所看到的,uglify配置为压缩多个文件,并且只指定一个源映射。 (我无法找出指定多个源映射输出的方法)。

As you can see, uglify is configured to compress multiple files, and there is only one source-map specified. (I am not able to figure out a way to specify multiple sourcemap outputs).

另外,uglify在压缩每个js文件后覆盖了soucemap。

Also, uglify is overwriting the soucemap after compressing each js file.

如何配置此插件输出所有js文件的完整源代码映射?

How do I configure this plugin to output the complete source-maps for all my js files?

推荐答案

您可以在sourceMap中设置函数。
$ b

You can set functtion at sourceMap.

uglify: {
  options: {
      sourceMap: function(path) { return path.replace(/.js/,".map")} 
  },
  .....

这篇关于如何在uglify grunt任务中指定多个源图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆