grunt-contrib-coffee one-to-one compile
coffeescript, gruntjs
Solution
The problem lies on the filenames having multiple dots. If it was jquery-a-b.coffee, jquery-a-c.coffee etc, you would have seen the expected output.
It is a known issue (extension is after last period only) and grunt developers made this on purpose. Here is a quote from one of them:
There's two ways ext could work; it could consider everything after the first dot the extension, or everything after the last dot the extension. We chose the former because the use-case is more common (we encounter .min.js files all the time). That being said, you can use the rename option to specify a function that will use whatever custom naming logic you need.
So, the only workaround for now is to remove `ext` and use `rename` like this:
coffee: {
dist: {
files: [{
expand: true,
cwd: 'app/webroot/coffee',
src: ['{,*/}*.coffee'],
dest: 'app/webroot/js',
rename: function(dest, src) {
return dest + '/' + src.replace(/\.coffee$/, '.js');
}
}]
}
}
Update as of Grunt 0.4.3: You can now use the `extDot` option along with `ext`
ext: '.js',
extDot: 'last'
Problem
I have several files named: - jquery.a.b.coffee - jquery.a.c.coffee - jquery.a.d.coffee and they are all compiled into one `jquery.js` file in my output directory. Although I guess this behavior might be nice in some cases, I would like to have them to compile into different files like `jquery.a.b.js`, `jquery.a.c.js` and so on. How can I tell grunt-contrib-coffeescript to do so? My Gruntfile.js looks like this: ``` module.exports = function (grunt) { grunt.initConfig({ coffee: { dist: { files: [{ expand: true, flatten: true, cwd: 'app/webroot/coffee', src: ['{,*/}*.coffee'], dest: 'app/webroot/js', ext: '.js' }] } } }); grunt.loadNpmTasks('grunt-contrib-coffee'); }; ``` Thanks for your help!