Created
August 6, 2013 07:00
-
-
Save mawatari/6162678 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 = function (grunt) { | |
'use strict'; | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
jshint: { | |
all: [ | |
'Gruntfile.js', | |
'src/js/models/*.js', | |
'src/js/collections/*.js', | |
'src/js/views/*.js', | |
'src/js/app.js', | |
'src/js/namespace.js' | |
] | |
}, | |
// Compassのコンパイル | |
compass: { | |
dist: { | |
options: { | |
config: 'config.rb' | |
} | |
} | |
}, | |
// CSSのminify: expanded, compressed 両ファイルを作るため、compassではminifyしない | |
cssmin: { | |
minify: {expand: true, src: ['assets/css/style.css'], ext: '.min.css'} | |
}, | |
// テンプレートファイルのプリコンパイル | |
handlebars: { | |
compile: { | |
options: { | |
namespace: 'MyApp.Templates', | |
processName: function (filename) { | |
var pieces = filename.split('/'); | |
return pieces[pieces.length - 1].replace(/.hbs$/, ''); | |
} | |
}, | |
files: { | |
'src/js/templates/layout.js': 'src/hbs/*.hbs' | |
} | |
} | |
}, | |
// ファイル結合の設定 | |
concat: { | |
dist: { | |
src: [ | |
'src/js/namespace.js', | |
'src/js/templates/*.js', | |
'src/js/models/*.js', | |
'src/js/collections/*.js', | |
'src/js/views/*.js', | |
'src/js/app.js' | |
], | |
dest: 'assets/js/app.js' | |
}, | |
dev: { | |
src: [ | |
'src/js/namespace.js', | |
'src/js/templates/*.js', | |
'src/js/models/*.js', | |
'src/js/collections/*.js', | |
'src/js/views/*.js', | |
'src/js/app.js' | |
], | |
dest: 'assets/js/app.min.js' | |
} | |
}, | |
// ファイル圧縮の設定 | |
uglify: { | |
options: { | |
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', | |
report: 'gzip' | |
}, | |
build: { | |
src: 'assets/js/app.js', | |
dest: 'assets/js/app.min.js' | |
} | |
}, | |
// gzip | |
compress: { | |
main: { | |
options: { | |
mode: 'gzip' | |
}, | |
files: [ | |
{expand: true, src: ['assets/js/app.min.js']} | |
] | |
} | |
}, | |
watch: { | |
files: [ | |
'src/**', | |
'!src/js/templates/layout.js' | |
], | |
tasks: ['dev'] | |
} | |
}); | |
// プラグインのロード | |
grunt.loadNpmTasks('grunt-contrib-compass'); | |
grunt.loadNpmTasks('grunt-contrib-compress'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-cssmin'); | |
grunt.loadNpmTasks('grunt-contrib-handlebars'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// Distribution | |
grunt.registerTask('build', ['jshint', 'compass', 'cssmin', 'handlebars', 'concat', 'uglify', 'compress']); | |
// Development | |
grunt.registerTask('dev', ['compass', 'cssmin', 'handlebars', 'concat:dev']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment