4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

coffeescript, jade, stylus, expressを利用する際のGruntfile.coffee

Last updated at Posted at 2014-09-10

以下の設定で、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']

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?