Using coffeescript with kanso
The Automatic Way
Add coffee-script-precompiler to your dependencies in kanso.json.
"dependencies": {
...
"coffee-script-precompiler": null
}
Add a coffee-script field to kanso.json with one or both of the following: a list of folders to search for coffeescript modules and a list of folders to search for coffeescript attachments.
"coffee-script": {
"modules": ["lib", "tests"],
"attachments": ["js"]
},
Run kanso install from your terminal to install dependencies. When you kanso push:
- All coffeescript modules listed in
coffee-script.moduleswill be compiled to javascript and uploaded as usual. - All coffeescript files in
attachementsdirectories will be uploaded as attachments at the corrosponding path with a.jsextension. So/lib/js/main.coffeewill be uploaded to/lib/js/main.js.
The Manual Way
Good for package development where you don't intend to directly kanso push your app.
Dependencies
Install Guard and Guard Coffeescript.
Setup
Put this in a Guardfile at the root of your project.
guard 'coffeescript', :output => 'lib', :bare => true do
watch(%r{src/(.+\.coffee)})
end
Run
Start Guard by (in a terminal) running guard in your project's root directory.
Write your Coffeescript files in the src directory of the root of your project. Guard watches for changes and generates javascript source files in the lib directory of the root of your project.
Extras
Guard will only generate javascript files when they are changed. To generate javascript for all documents in the src directory every time you start guard add :all_on_start => true to your Guardfile. It will look like this.
guard 'coffeescript', :output => 'lib', :bare => true, :all_on_start => true do
watch(%r{src/(.+\.coffee)})
end