1

I have a requirejs project, I'm compiling with grunt-requirejs ("grunt-contrib-requirejs": "~0.4.1") into 1 big file: main.js. This task has source map generation enabled:

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 } } }

After that I minify this main.js with grunt-uglify ("grunt-contrib-uglify": "~0.2.7") using this configuration:

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'] } }

I would like to have a source map that will tell me an error in the source files (the ones requirejs consumes), but instead source map refuses to work at all. Please help me to get there as I'm feeling helpless already.

Dmitry Evseev
  • 11,533
  • 3
  • 34
  • 48
  • Interesting to know if there is some resolution? – Olga Nov 02 '15 at 13:23
  • @Olga the way I made it work was to follow this answer: http://stackoverflow.com/a/25081693/637740 . Generally it's parsing maps with a 3-rd party library, maps are downloaded only when the error happened. – Dmitry Evseev Nov 02 '15 at 19:18
  • I'm having a similar issue, looks like requirejs does not include the baseUrl or appDir when creating the source maps so the mapping is wrong. – frontsidebus Apr 27 '16 at 00:28

1 Answers1

0

grunt-require comes with it's own uglify package built in:

eg.

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"
        }
    }
}
Croot
  • 331
  • 1
  • 10
  • It can work at this project, I will try that, thanks. Though at later projects I use ngAnnotate tool to prepare the code before minifying. That's why process split into 2 jobs and unfortunately won't work as a single task – Dmitry Evseev Mar 13 '15 at 14:58