For example, write the coffee file in the coffee/controller/folder, create a new Js/controller folder, use the grunt to run the project, will automatically compile coffee to the corresponding JS folder.
Module.exports = function (grunt) {//project configuration information. Grunt.initconfig ({pkg:grunt.file.readJSON (' Package.json '), Jshint: {options: {jshintrc: '. Jshintrc ') ,//Eqeqeq:true,//Tradiling:true, ignores: [' Node_modules/**/*.js ']}, all: [' **/*.js ' ]}, coffee:{compile: {options: {sourcemap:false, bare:true}, file S: [{expand:true, CWD: ' coffee/', src: ' **/*.coffee ', dest: ' js/', ext: '. J S '}]}, watch: {coffee: {files: [' **/*.coffee '], tasks: [' coffee:compile '] },//JS: {//files: [' **/*.js '],//tasks: [' jshint '],//options: {///Livereload : True/}}, Nodemon: {dev: {script: ' bin/www ', options: {args: [], Ignoredfiles: [], watchedextensions: [' JS '], watchedfolders: ['./'], Debug:true, Delaytime:1, env: {port:3000}, CWD: __dirname }}, concurrent: {tasks: [' watch ', ' Nodemon '], options: {logconcurrentoutput:true} } }); Load the "uglify" plugin: Grunt.loadnpmtasks (' Grunt-contrib-watch '); Grunt.loadnpmtasks (' Grunt-contrib-coffee '); Grunt.loadnpmtasks (' Grunt-contrib-jshint '); Grunt.loadnpmtasks (' Grunt-nodemon '); Grunt.loadnpmtasks (' grunt-concurrent '); Grunt.loadnpmtasks (' grunt-ssh '); Grunt.option (' Force ', true); Registers the default task. Grunt.registertask (' Default ', [' concurrent ']);
Automatic compilation of Coffeescript Gruntfile.js