Reputation: 2415
I want to compile a coffeescript file in custom grunt task that I am building. I want to be able to call grunt plugins from custom grunt tasks. This is the code that I am trying at this point:
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.registerTask('start', 'Starting compilation,', () ->
grunt.log.write('Logging some stuff...').ok()
grunt.coffee()
)
My code is clearly wrong, but I am wondering how can I set the options of the coffee plugin and call it from this custom plugin. That way I'll be able to loop through and perform a custom compilation/build task.
Upvotes: 0
Views: 67
Reputation: 13762
Try something like this (a dynamic alias task):
grunt.initConfig
coffee: {}
grunt.registerTask 'start', 'Starting compilation,', ->
grunt.log.write('Logging some stuff...').ok()
grunt.config('coffee.target', { src: ['files'], dest: 'dist/out.js' })
grunt.task.run(['coffee:target'])
grunt.loadNpmTasks 'grunt-contrib-coffee'
When entering grunt start
it will configure the coffee task and then run it immediately after the start
task has finished.
Upvotes: 0