uglified requirejs项目中的源映射

时间:2015-01-12 17:10:20

标签: requirejs gruntjs uglifyjs2

我有一个requirejs项目,我正在使用grunt-requirejs"grunt-contrib-requirejs": "~0.4.1")编译成一个大文件:main.js。此任务已启用源映射生成:

requirejs: { compile: { options: { baseUrl: 'source/js', name: 'main', optimize: 'none', generateSourceMaps: true, out: 'build/js/main.js', wrap: true, shim: requireJsConfig.shim, paths: requireJsConfig.paths } } }

之后,我使用此配置将此main.jsgrunt-uglify"grunt-contrib-uglify": "~0.2.7")缩小:

app: { options: { beautify : { quote_keys: true }, compress: false, report: 'min', sourceMap: 'build/js/main.js.map', sourceMapIn: 'build/js/main.js.map', // input from requirejs sourceMapIncludeSources: true }, files: { 'build/js/main.js': ['build/js/main.js'] } }

我想有一个源地图,告诉我源文件中的错误(需要消耗的那些),但源地图拒绝工作。请帮助我到那里,因为我已经感到无助了。

1 个答案:

答案 0 :(得分:0)

grunt-require附带了内置的uglify包:

例如

requirejs: {
    compile: {
        options: {
            generateSourceMaps: true,
            logLevel: 4,
            baseUrl: "common/scripts/",
            include: "./main",
            out: "common/dist/main.js",
            preserveLicenseComments: false,
            optimize: "uglify2",
            mainConfigFile: "common/scripts/main.js"
        }
    }
}