以下の設定で、jade,coffee,stylファイルを更新した際、自動でhtml, js, cssファイルを生成。
さらに何もしなくてもページ更新走ってくれる。(パスは各自設定)
ブラウザのアプリインストールする必要あるけど、livereroadすばらしすぎる
grunt defaultで起動
Gruntfile.coffee
module.exports = (grunt) ->
grunt.initConfig
coffee:
app:
expand: true
cwd: 'src/'
src: '**/*.coffee'
dest: './'
ext: '.js'
jade:
default:
expand: true
cwd: 'src/public/partials'
src: '*.jade'
dest: 'public/partials'
ext: '.html'
stylus:
default:
expand: true
cwd: 'src/'
src: '**/*.styl'
dest: './'
ext: '.css'
copy:
main:
files: [
src: "src/views/index.jade"
dest: "views/index.jade"
]
express:
dev:
options:
script: 'bin/www'
watch:
options:
livereload: true
coffee:
files: '**/*.coffee',
tasks: ['coffee']
jade:
files: 'src/public/partials/*.jade',
tasks: ['jade']
stylus:
files: '**/*.styl',
tasks: ['stylus']
copy:
files: 'src/views/*.jade'
tasks: ['copy']
express:
files: 'src/*'
tasks: ['express']
options: {
spawn: false
}
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-jade'
grunt.loadNpmTasks 'grunt-contrib-stylus'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-express-server'
grunt.registerTask 'default', ['express', 'watch']