Created
March 10, 2014 09:16
-
-
Save takahiro47/9461833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (grunt) -> | |
'use strict' | |
require 'coffee-script' | |
require 'coffee-errors' | |
# Load grunt tasks automatically | |
require('load-grunt-tasks') grunt, | |
scope: 'devDependencies' | |
# Time how long tasks take. Can help when optimizing build times | |
require('time-grunt') grunt | |
## Tasks | |
grunt.registerTask 'serve', (target) -> | |
if target is 'dist' | |
return grunt.task.run [ 'build', 'connect:dist:keepalive', ] | |
grunt.task.run [ 'test', 'connect:livereload', 'watch' ] | |
return | |
grunt.registerTask 'server', -> | |
grunt.log.warn 'The `server` task has been deprecated. Use `grunt serve` to start a server.' | |
grunt.task.run ['serve'] | |
return | |
grunt.registerTask 'build', [ 'copy', 'coffee', 'uglify', 'stylus', 'cssmin', 'jade', 'imagemin', 'svgmin', 'htmlmin' ] | |
# grunt.registerTask 'test', [ 'coffeelint', 'build', 'csslint', 'simplemocha', 'play' ] | |
grunt.registerTask 'test', [ 'coffeelint', 'build', 'simplemocha', 'play' ] | |
grunt.registerTask 'default', [ 'serve' ] | |
## Config | |
grunt.option 'force', yes | |
grunt.initConfig | |
pika: | |
dist: 'dist/' | |
public: 'public/' | |
pkg: grunt.file.readJSON 'package.json' | |
watch: | |
options: | |
spawn: no | |
interrupt: yes | |
livereload: yes | |
dateFormat: (time) -> | |
grunt.log.writeln "The watch finished in #{time}ms at #{new Date().toLocaleTimeString()}" | |
dist: | |
files: [ '**/*.coffee', 'assets/**/*.jade', 'assets/**/*.styl' ] | |
tasks: [ 'test' ] | |
# coffee: | |
# files: [ 'assets/**/*.coffee'] | |
# tasks: [ 'coffeelint', 'coffee', 'uglify' ] | |
# jade: | |
# files: [ 'assets/**/*.jade' ] | |
# tasks: [ 'jade' ] | |
# stylus: | |
# files: [ 'assets/**/*.styl'] | |
# tasks: [ 'stylus', 'csslint', 'cssmin' ] | |
gruntfile: | |
files: [ 'Gruntfile.coffee' ] | |
tasks: [ 'test' ] | |
livereload: | |
options: | |
livereload: '<%= connect.options.livereload %>' | |
files: [ | |
'assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' | |
] | |
tasks: [ 'test' ] | |
# The actual grunt server settings | |
connect: | |
options: | |
port: 8000 | |
hostname: 'bosai.sfc.keio.ac.jp' # Change this to '0.0.0.0' to access the server from outside. | |
livereload: 35729 | |
livereload: | |
options: | |
open: yes | |
base: '.' | |
dist: | |
options: | |
base: 'dist/' | |
copy: | |
img: | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '**/*.{jpg,png,gif}' ] | |
dest: 'dist/' | |
}] | |
js: | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '**/*.js' ] | |
dest: 'dist/' | |
}] | |
css: | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '**/*.css' ] | |
dest: 'dist/' | |
}] | |
source: | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '**/*.coffee' ] | |
dest: 'dist/' | |
}] | |
coffeelint: | |
options: | |
max_line_length: | |
value: 319 # 79 | |
indentation: | |
value: 2 | |
newlines_after_classes: | |
level: 'error' | |
no_empty_param_list: | |
level: 'error' | |
no_unnecessary_fat_arrows: | |
level: 'ignore' | |
dist: | |
files: [ | |
{ expand: yes, cwd: 'assets/', src: [ '**/*.coffee' ] } | |
{ expand: yes, cwd: 'config/', src: [ '**/*.coffee' ] } | |
{ expand: yes, cwd: 'events/', src: [ '**/*.coffee' ] } | |
{ expand: yes, cwd: 'helper/', src: [ '**/*.coffee' ] } | |
{ expand: yes, cwd: 'models/', src: [ '**/*.coffee' ] } | |
{ expand: yes, cwd: 'tests/', src: [ '**/*.coffee' ] } | |
] | |
csslint: | |
options: | |
csslintrc: '.csslintrc' | |
strict: | |
options: | |
import: 2 | |
src: 'dist/**/*.css' | |
coffee: | |
options: | |
sourceMap: yes | |
sourceRoot: '' | |
bare: yes | |
#> Angular.jsによってglobal空間でオブジェクトを使いまわす | |
separator: 'linefeed' | |
compile: | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '*.coffee', '**/*.coffee' ] | |
dest: 'dist/' | |
ext: '.js' | |
}] | |
stylus: | |
options: | |
compress: no | |
compile: | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '*.styl', '**/*.styl' ] | |
dest: 'dist/' | |
ext: '.css' | |
}] | |
jade: | |
debug: | |
pretty: yes | |
data: version: '<%- pkg.version %>' | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '*.jade', '**/*.jade' ] | |
dest: 'dist/' | |
ext: '.html' | |
}] | |
compile: | |
options: | |
data: version: '<%- pkg.version %>' | |
files: [{ | |
expand: yes | |
cwd: 'assets/' | |
src: [ '*.jade', '**/*.jade' ] | |
dest: 'public/' | |
ext: '.html' | |
}] | |
uglify: | |
dist: | |
options: | |
mangle: on | |
files: [{ | |
expand: yes | |
cwd: 'dist/' | |
src: [ '*.js', '**/*.js' ] | |
dest: 'public/' | |
ext: '.js' | |
}] | |
cssmin: | |
dist: | |
files: [{ | |
expand: yes | |
cwd: 'dist/' | |
src: [ '*.css', '**/*.css' ] | |
dest: 'public/' | |
ext: '.css' | |
}] | |
imagemin: | |
dist: | |
files: [{ | |
expand: yes | |
cwd: 'dist/' | |
src: [ '*.{jpg,png,gif}', '**/*.{jpg,png,gif}' ] | |
dest: 'public/' | |
}] | |
svgmin: | |
dist: | |
files: [ | |
expand: yes | |
cwd: 'dist/' | |
src: '{,*/}*.svg' | |
dest: 'public/' | |
] | |
htmlmin: | |
dist: | |
options: | |
collapseWhitespace: yes | |
collapseBooleanAttributes: yes | |
removeCommentsFromCDATA: yes | |
removeOptionalTags: yes | |
files: [ | |
expand: yes | |
cwd: 'views/' | |
src: [ '*.{html}', '**/*.{html}' ] | |
dest: 'public/' | |
] | |
simplemocha: | |
options: | |
ui: 'bdd' | |
reporter: 'spec' | |
compilers: 'coffee:coffee-script' | |
ignoreLeaks: no | |
dist: | |
src: [ 'tests/test.coffee' ] | |
play: | |
fanfare: | |
# file: 'node_modules/grunt-play/sounds/fanfare.mp3' | |
file: 'assets/sounds/ta_ta_pi01.mp3' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment