Grunt

Grunt是JavaScript项目构建工具。

1. 使用grunt-contrib-uglify压缩JavaScript代码时

配置grunt-contrib-uglify插件以生成Source Map

grunt.initConfig(
{
    uglify:
    {
        options:
        {
            sourceMap: true
        }
    }
});
2. 使用grunt-usemin打包源码时

grunt-usemin会依次调用grunt-contrib-concatgrunt-contrib-uglify对源码进行打包和压缩。因此都需要进行配置:

grunt.initConfig(
{
    concat:
    {
        options:
        {
            sourceMap: true
        }
    },
    uglify:
    {
        options:
        {
            sourceMap: true,
            sourceMapIn: function(uglifySource)
            {
                return uglifySource + '.map';
            },
        }
    }
});

results matching ""

    No results matching ""