Audun Olsen
Audun Olsen

Reputation: 638

Coffeescript source map doesn’t reference original files, but a new concated file

I’m using grunt-contrib-coffee to compile the following:

into:

This works, but the problem is that a third file is generated in dist/js called “concated.src.coffee”, this is the file that concated.js.map references. This is of no use to me, when i debug in the browser i want the sourcemap to reference the original files, not a concated coffee file.

My grunt coffee config:

module.exports =

compileWithMaps:
  options:
     sourceMap: true
  files: 'dist/js/concated.js': 'src/coffee/*.coffee’

Any thoughts on how to make the sourcemap reference original files, not a generated concated coffee file?

Upvotes: 1

Views: 51

Answers (1)

Audun Olsen
Audun Olsen

Reputation: 638

Found a way to make it work!

Instead of letting grunt-contrib-coffee concat all .coffee files, I intstead changed the task configuration to compile all the files individually and place them all in a folder like so:

glob_to_multiple:
    options:
        sourceMap: true
    expand: true
    flatten: true
    cwd: 'src/'
    src: ['**/*.coffee']
    dest: 'dist/compile-coffee'
    ext: '.js’

To concat the files and the related sourcemaps, I used grunt-concat-with-sourcemaps and configured the task like so:

your_target:
    options:
        sourceRoot: '../../'
    files: 'dist/concat-js/concat.js': [ 'dist/compile-coffee/*.js’ ]

Upvotes: 0

Related Questions