0

So, I have a project with a layout of

src
--library
----a.coffee
----b.coffee
----c.coffee
--demo
----main.coffee

I have grunt set up currently to compile coffeescript in src/library to intermediate/library, concat the results to intermediate/library.js and put in dist

This works fine, but now I want to also watch src/demo and do the same thing, how would I go about this?

My grunt file is:

module.exports = (grunt) ->
  grunt.loadNpmTasks("grunt-contrib-coffee")
  grunt.loadNpmTasks("grunt-contrib-watch")
  grunt.loadNpmTasks("grunt-contrib-concat")

  grunt.initConfig
    watch:
      coffee:
        files: "src/library/**/*.coffee"
        tasks: ["coffee:compile", "concat"]

    coffee:
      compile:
        expand: true,
        flatten: true,
        cwd: "src/library",
        src: ["**/*.coffee"],
        dest: "intermediate/library/",
        ext: ".js"

    concat:
      options:
        separator: ";"
      dist:
        src: ["intermediate/library.js", "intermediate/library/**/*.js"]
        dest: "dist/library.js"

  grunt.registerTask "default", ["watch"]
Michael Baldry
  • 1,990
  • 2
  • 14
  • 28

1 Answers1

0

Ok, I've worked it out.

watch: # specific name for the task that I want to run
  anyName: # name of my specific configuration of the task

So I can do

concat:
  options:
    separator: ";"
  library:
    src: ["intermediate/library.js", "intermediate/library/**/*.js"]
    dest: "dist/library.js"
  demo:
    src: ["intermediate/demo.js", "intermediate/demo/**/*.js"]
    dest: "dist/demo.js"

for example

Michael Baldry
  • 1,990
  • 2
  • 14
  • 28