0

Code that I have:

coffee: { compile: { files: { 'server/api/**/*.js': ['server/api/**/*.coffee'] // compile and concat into single file } } }, 

Meaning, the target Dir should be the same where the .coffee file was found. Above code in Grunt does however create the directory "**" and puts the file "*.js" into it.

This is what I want:

server/api/sample/sample.coffee -> server/api/sample/sample.js server/api/sample2/sample2.coffee -> server/api/sample2/sample2.js 

1 Answer 1

1

To compile your files dinamically you have to do it:

glob_to_multiple: { expand: true, flatten: true, cwd: 'server/api', src: ['**/*.coffee'], dest: 'server/api', ext: '.js', extDot: 'last' } 
Sign up to request clarification or add additional context in comments.

3 Comments

Grunt creates the folder and file for you, you only need to pass the base path, in your case server/api. If you have a .coffee file in server/api/foo/foo.coffee, the destination will be server/api/foo/foo.js.
So far so good, with "flatten: false" stuff happens as described by your last comment. Except... for files like this "myFile.controller.coffee", they get renamed to "myFile.js". Any ideas?
Try with extDot: 'last'. In the documentation is better explained: gruntjs.com/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.