kwsktr's study log

kwsktr のおべんきょログ

grunt の サンプル :: package.json と gruntfile.coffee

サンプルがないと不便と言われたので。


Prod 環境だけを抜き出したサンプルだけど、たぶん動くはず。
いまよりも便利にしたいけれど、モチベーションが起きないのは効率良く使えてないからだと思う。

package.json

{
  "name": "works",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {},
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-clean": "^0.6.0",
    "grunt-contrib-coffee": "^0.11.1",
    "grunt-contrib-compass": "^0.9.1",
    "grunt-contrib-less": "^0.11.4",
    "grunt-contrib-watch": "^0.6.1",
    "load-grunt-tasks": "^0.6.0"
  }
}

gruntfile.coffee

#gruntfile.coffee
module.exports = (grunt) ->

	# load all grunt tasks matching the `grunt-*` pattern
	require('load-grunt-tasks')(grunt)

	grunt.initConfig
		clean:
			build:
				options:
					force: true
				src: [
					'../path/css/*'
					'!../path/css/sns.min.css'
					'../path/js/src/app.js'
				]

		less:
			prod:
				options:
					path: '../path/less'
					compress: true
				files:
					'../path/css/sample.css': '../path/less/sample.less'

		compass:
			prod:
				options:
					config: '../path/config.rb'

		coffee:
			compile:
				files:
					'../path/js/src/app.js': '../path/coffee/src/app.coffee'

		watch:
			less:
				tasks: 'less:prod'
				files: '../path/less/*.less'
			compass:
				tasks: 'compass:prod'
				files: '../path/scss/*'
			coffee:
				tasks: 'coffee:compile'
				files: '../path/coffee/*'


	grunt.registerTask 'default', [
		'clean'
		'less'
		'compass'
		'coffee'
		'watch'
	]


まだ yeoman.io を試せていないので、はやいところ当たり前のように使って楽をしたい。