A
A
Andrey Chernyshev2014-01-01 15:09:38
Node.js
Andrey Chernyshev, 2014-01-01 15:09:38

Grunt task to build coffeescript file to file

Good afternoon.
I'm trying to figure out how to write a taxi for grunt so that it collects my coffee scripts in the same files, only js.
For example, the structure:
blocks
header
header.coffee
# I want header.js to be here after compilation and I don't want to manually write in gruntfile for each such path file.
That is, I want to collect */*.coffee in the same place as the original coffee.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hldr, 2014-01-02
@hldr

I guess you should use the standard grunt-contrib-coffee with settings like this:

coffee: 
      main:
        expand: true
        cwd:  "/"
        src: ["**/*.coffee"]
        dest:  "/"
        ext:  ".js"

N
Nikita Hrytsai, 2014-01-11
@CookiesInChocolate

I assume node.js and grunt-sli are already installed. Put grunt-contrib-coffee
in the project folder Create a gruntfile.js with the following content:

module.exports = function(grunt){
  grunt.initConfig({
    coffee:{
      compile:{
        files:{
          'coffee/script.js' : 'coffee/script.coffee'
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.registerTask('default', 'coffee')
}

"coffee/script.coffee" is the source file, and coffee/script.js is the compilation result, respectively.
If not, please describe the problem in more detail =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question