Ionic Framework+coffeescript

Ionic Frameworkのインストール

# sudo npm install -g cordova ionic

ひな形作成

$ ionic start ionic-coffee blank
$ cd ionic-coffee/ionic-app-base-master/

gulpfile.jsとapp.jsの変換

coffee-scriptを入れる

$ npm install --save-dev coffee-script     

js2coffeeのインストール

# sudo npm install -g js2coffee

変換

$ js2coffee gulpfile.js > gulpfile.coffee
$ mkdir coffee
$ js2coffee www/js/app.js > coffee/app.coffee

gulpfile.jsの書き換え

$ vim gulpfile.js
require('coffee-script/register');
require('./gulpfile.coffee');

coffeescriptコンパイル

gulp-coffeeを入れる

$ npm install --save-dev gulp-coffee

gulpfile.coffeeの編集

~~~
coffee = require('gulp-coffee')
~~~
~~~
gulp.task 'coffee', ->
  gulp.src('./coffee/*.coffee')
  .pipe(coffee({bare: true}).on('error', gutil.log))
  .pipe(gulp.dest('./www/js/'))
~~~

ブラウザで確認

ripple emulator を入れる

# npm install -g ripple-emulator

確認

$ gulp coffee
$ ripple emulate --path www/