Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile to `.js` maintaining the same folder structure

In my app (Asp.net mvc) I have the following folder structure:

Foder structure

Scripts folder contains all .js and .coffee files. Inside the folder Controllers I have a folder for each controller.

I need that whenever a .coffee file changed, a new file .js is created in the same folder with the same name.

module.exports = (grunt) -> 
    # Configurações
    grunt.initConfig
        coffee:
            compile:
                options:
                    basePath: 'Scripts'
                    preserve_dirs: true
                files: 'Scripts/*.js': 'Scripts/**/*.coffee'

    # Plugins
    grunt.loadNpmTasks 'grunt-contrib-coffee'

When I run grunt: grunt coffee the following error occurs:

Unable to write "Scripts/*.js" file (Error code: ENOENT). Use --force to continue

Erro grunt

like image 327
ridermansb Avatar asked Feb 17 '26 02:02

ridermansb


1 Answers

use it that way:

coffee:
  compile:
    files: [
      expand: true
      cwd: "./Scripts"
      src: ["**/*.coffee"]
      dest: "./Scripts"
      ext: ".js"       
    ]

read more about it here: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

like image 159
hereandnow78 Avatar answered Feb 19 '26 14:02

hereandnow78



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!