1

I am new to Grunt/Yeoman and I have an existing app with 40+ Coffeescript files like this:

scripts/
  lib/
    ...
  common/
    ...
  util/
    ...
  app/
    views/
    models/
      A.cofffee
      B.cofffee
      C.cofffee

I want to concatenate them in a specific order and compile into one file.

So I'd like to say "compile in this order"

scripts/lib/some_superclass.coffee
scripts/lib/*
common/*
util/app/views/*
util/app/models/some_model_that_needs_to_be_required_first.coffee
util/app/models/*

How is this problem tackled in Grunt/Yeoman projects? (I really don't want to spell each file out)

hakunin
  • 4,041
  • 6
  • 40
  • 57

1 Answers1

7

In your GruntFile.js, you should have a coffee step like:

// Coffee to JS compilation
coffee: {
  compile: {
    files: {
      'temp/scripts/*.js': 'app/scripts/**/*.coffee' 
    },
    options: {
      basePath: 'app/scripts'
    }
  }
},
...

Normally, you should be able to do:

    files: {
      '/path/to/destination/index.js': [
        'scripts/lib/some_superclass.coffee', 
        'scripts/lib/**/*.coffee', 
        'common/**/*.coffee',
        #...
      ] 
    },
hakunin
  • 4,041
  • 6
  • 40
  • 57
asgoth
  • 35,552
  • 12
  • 89
  • 98