LoginSignup
32
32

More than 5 years have passed since last update.

CoffeeScriptでモジュールを作る際のGruntfile.coffee

Posted at

毎回使うパターンだったので書いておく。
ファイル結合 + mochaによるテスト

$ npm install grunt grunt-contrib grunt-simple-mocha --save-dev

Gruntfile.coffee

module.exports = (grunt) ->
  grunt.loadNpmTasks 'grunt-contrib'
  grunt.loadNpmTasks 'grunt-simple-mocha'

  grunt.initConfig
    connect:
      server:
        options:
          port: 8888
          base: '.'

    watch:
      coffee:
        files: "src/**/*.coffee",
        tasks: ["coffee"]

      coffee_with_test:
        files: ["src/**/*.coffee", 'test/**/*_test.coffee'],
        tasks: ["coffee:compile", 'simplemocha']

    coffee:
      compile:
        files:
          'dist/all.js': [
            "src/**/*.coffee"
          ]

    simplemocha:
      options:
        globals: ['should']
        timeout: 3000
        ignoreLeaks: false
        ui: 'bdd'
        reporter: 'spec'
        compilers: 'coffee:coffee-script'
      all:
        src: 'test/**/*.coffee'

  grunt.registerTask "run", ["coffee","connect", "watch:coffee"]
  grunt.registerTask "run_with_test", ["coffee","connect", "watch:coffee_with_test"]
32
32
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
32
32