Skip to content

Instantly share code, notes, and snippets.

@cu39
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cu39/9969269 to your computer and use it in GitHub Desktop.
Save cu39/9969269 to your computer and use it in GitHub Desktop.
シンプルなWebサーバ+LivereloadだけのGruntfile ref: http://qiita.com/cu39/items/29a0322e7e86f616ee3c
{
"name": "greeter",
"version": "0.0.0",
"description": "",
"main": "greeter.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "cu39",
"license": "MIT",
"devDependencies": {
"grunt": "^0.4.4",
"grunt-concurrent": "^0.5.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-typescript": "^0.3.0",
"load-grunt-tasks": "^0.4.0",
"time-grunt": "^0.3.1"
}
}
'use strict'
# # Globbing (元のコメントを翻訳)
# パフォーマンスを上げるため1階層下だけにマッチさせている:
# 'test/spec/{,*/}*.js'
# すべてのサブフォルダに再帰的にマッチさせたいならこちらを使う:
# 'test/spec/**/*.js'
module.exports = (grunt) ->
# Show elapsed time after tasks run
require('time-grunt') grunt
# Load all Grunt tasks
require('load-grunt-tasks') grunt
grunt.initConfig
# Project settings
config:
# Configurable paths
app: '.'
css: '<%= config.app %>/.'
ts: '<%= config.app %>/.'
js: '<%= config.app %>/.'
# grunt-contrib-watch
watch:
typescript:
files: ['<%= config.ts %>/{,*/}*.ts']
tasks: ['typescript:server']
livereload:
options:
livereload: '<%= connect.options.livereload %>'
files: [
'<%= config.app %>/{,*/}*.html'
'<%= config.css %>/{,*/}*.css'
'<%= config.js %>/{,*/}*.js'
]
# grunt-typescript
typescript:
options: {}
server:
src: ['<%= config.ts %>/**/*.ts']
dest: '<%= config.js %>/greeter.js'
optionj:
module: 'amd'
target: 'es5'
# grunt-contrib-connect
connect:
options:
port: 9000
livereload: 35729
# change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
livereload:
options:
open: true
base: ['<%= config.app %>']
# grunt-concurrent
concurrent:
server: [
'typescript:server'
]
# end of grunt.initConfig
# register tasks
grunt.registerTask 'serve', ->
grunt.task.run [
'concurrent:server'
'connect:livereload'
'watch'
]
grunt.registerTask 'default', ['serve']
"use strict"
# # Globbing
# for performance reasons we're only matching one level down:
# 'test/spec/{,*/}*.js'
# use this if you want to recursively match all subfolders:
# 'test/spec/**/*.js'
module.exports = (grunt) ->
# Show elapsed time after tasks run
require("time-grunt") grunt
# Load all Grunt tasks
require("load-grunt-tasks") grunt
grunt.initConfig
# grunt-contrib-watch
watch:
typescript:
files: ["./{,*/}*.ts"]
tasks: ["typescript:server"]
livereload:
options:
livereload: '<%= connect.options.livereload %>'
files: [
'./{,*/}*.html'
'./{,*/}*.css'
'./{,*/}*.js'
]
# grunt-typescript
typescript:
options: {}
server:
src: ["**/*.ts"]
dest: "greeter.js"
options:
module: 'amd'
target: 'es5'
# grunt-contrib-connect
connect:
options:
port: 9000
livereload: 35729
# change this to '0.0.0.0' to access the server from outside
hostname: "localhost"
livereload:
options:
open: true
base: ['.']
# grunt-concurrent
concurrent:
server: [
'typescript:server'
]
# end of grunt.initConfig
# register tasks
grunt.registerTask "serve", ->
grunt.task.run [
"concurrent:server"
'connect:livereload'
'watch'
]
{
"name": "greeter",
"version": "0.0.0",
"description": "",
"main": "greeter.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "cu39",
"license": "MIT",
"devDependencies": {
"grunt": "^0.4.4",
"grunt-concurrent": "^0.5.0",
"grunt-contrib-connect": "^0.7.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-typescript": "^0.3.0",
"load-grunt-tasks": "^0.4.0",
"time-grunt": "^0.3.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment