Skip to content

Instantly share code, notes, and snippets.

@mponizil
Created May 22, 2013 19:24
Show Gist options
  • Save mponizil/5630180 to your computer and use it in GitHub Desktop.
Save mponizil/5630180 to your computer and use it in GitHub Desktop.
fs = require 'fs'
path = require 'path'
module.exports = (grunt) ->
grunt.initConfig
coffee:
default:
expand: true
cwd: 'source/coffee'
src: ['**/*.coffee']
dest: 'library/js'
ext: '.js'
test:
expand: true
cwd: 'test/source'
src: ['**/*.coffee']
dest: 'test/library'
ext: '.js'
compass:
default:
options:
specify: ['source/scss/style.scss']
sassDir: 'source/scss'
cssDir: 'library/css'
imagesDir: 'library/img'
relativeAssets: true
importantify:
default: 'library/css'
watch:
coffee:
files: ['source/**/*.coffee', 'library/vendor/*.js']
tasks: ['coffee']
scss:
files: ['source/**/*.scss']
tasks: ['styles']
requirejs:
compile:
options:
baseUrl: 'library/js'
mainConfigFile: 'library/js/require-config.js'
name: '../vendor/almond'
include: ['main']
out: 'build/main.js'
qunit:
all:
options:
urls: ['http://localhost:8000/test/index.html']
connect:
example:
options:
keepalive: true
port: 8000
test:
options:
port: 8000
shell:
browser:
command: 'open http://127.0.0.1:8000/example/'
grunt.loadNpmTasks('grunt-shell')
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-requirejs')
grunt.loadNpmTasks('grunt-contrib-compass')
grunt.loadNpmTasks('grunt-contrib-watch')
grunt.loadNpmTasks('grunt-contrib-qunit')
grunt.loadNpmTasks('grunt-contrib-connect')
grunt.registerMultiTask 'importantify', "Add !important flags to every css rule.", ->
for file in fs.readdirSync(@data)
file = path.join(@data, file)
contents = fs.readFileSync(file).toString()
contents = contents.replace(/(.)(;|\})/g, '$1 !important$2')
fs.writeFileSync file, contents
grunt.registerTask('default', ['watch'])
grunt.registerTask('styles', "Run compass and importantify.", ['compass', 'importantify'])
grunt.registerTask('build', "Compile and build with rjs.", ['coffee', 'styles', 'requirejs'])
grunt.registerTask('test', "Compile test source and test with qunit.", ['coffee', 'connect:test', 'qunit'])
grunt.registerTask('example', "Launch example url in the browser.", ['shell:browser'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment