Created
July 8, 2013 20:36
-
-
Save swalkinshaw/5952277 to your computer and use it in GitHub Desktop.
Grunt connect-livereload with pushState rewrites
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
'use strict' | |
path = require 'path' | |
parse = require('url').parse; | |
module.exports = (grunt) -> | |
grunt.initConfig | |
qunit: | |
all: ['tests/**/*.html'] | |
clean: | |
all: ['.tmp/**/*.*', 'public/css', 'public/js'] | |
copy: | |
static: | |
files:[ | |
expand: true | |
cwd: 'app' | |
src: [ | |
'**/*.html' | |
'images/*' | |
'fonts/*' | |
] | |
dest: 'public/' | |
] | |
coffee: | |
options: | |
bare: true | |
sourceMap: true | |
glob_to_multiple: | |
expand: true | |
cwd: '' | |
src: [ | |
'app/**/*.coffee' | |
'tests/**/*.coffee' | |
] | |
dest: '.tmp/js' | |
ext: '.js' | |
commonjs: | |
modules: | |
cwd: '.tmp/js/app/js/' | |
src: '**/*.js' | |
dest: '.tmp/js/app/js/' | |
fixtures: | |
cwd: '.tmp/js/tests/fixtures' | |
src: '**/*.js' | |
dest: '.tmp/js/tests/fixtures' | |
stylus: | |
compile: | |
files: | |
'public/css/application.css': ['app/**/*.styl'] | |
cssmin: | |
compress: | |
files: | |
'public/css/application.css': ['public/css/application.css'] | |
emberTemplates: | |
compile: | |
options: | |
templateName: (sourceFile) -> | |
sourceFile.replace /app\/js\/templates\//, '' | |
files: | |
'.tmp/js/app/templates.js': ['app/**/*.handlebars'] | |
concat: | |
styles: | |
src: [ | |
'vendor/normalize.css' | |
'public/css/application.css' | |
] | |
dest: 'public/css/application.css' | |
tests: | |
src: [ | |
'tests/{integration,unit,fixtures}/**/*.js' | |
'.tmp/js/tests/**/*.js' | |
] | |
dest: 'tests/test_bundle.js' | |
precompile: | |
src: [ | |
'vendor/jquery.js' | |
'vendor/common.js' | |
'vendor/handlebars.runtime.js' | |
'vendor/ember.min.js' | |
'vendor/ember-data.min.js' | |
'.tmp/js/app/templates.js' | |
'.tmp/js/app/js/**/*.js' | |
] | |
dest: 'public/js/application.js' | |
scripts: | |
src: [ | |
'vendor/jquery.js' | |
'vendor/common.js' | |
'vendor/handlebars.runtime.js' | |
'vendor/ember.js' | |
'vendor/ember-data.js' | |
'.tmp/js/app/templates.js' | |
'.tmp/js/app/js/**/*.js' | |
] | |
dest: 'public/js/application.js' | |
uglify: | |
precompile: | |
files: | |
'public/js/application.js': ['public/js/application.js'] | |
watch: | |
options: | |
livereload: 35729 | |
coffee: | |
files: 'app/js/**/*.coffee' | |
tasks: ['default'] | |
options: | |
livereload: true | |
handlebars: | |
files: 'app/**/*.handlebars' | |
tasks: ['default'] | |
options: | |
livereload: true | |
stylus: | |
files: 'app/**/*.styl' | |
tasks: ['default'] | |
options: | |
livereload: true | |
static: | |
files: [ | |
'app/**/*.html' | |
'app/images/*' | |
'app/fonts/*' | |
] | |
tasks: ['default'] | |
options: | |
livereload: true | |
tests: | |
files: ['tests/integration/**/*.js', 'tests/integration/**/*.coffee'] | |
tasks: ['test'] | |
options: | |
livereload: true | |
connect: | |
server: | |
options: | |
base: 'public' | |
middleware: (connect, options) -> | |
[ | |
(req, res, next) -> | |
url = parse req.url | |
file = url.pathname.split('/').splice(-1)[0] | |
req.url = '/' unless path.extname(file) | |
next() | |
require('connect-livereload')() | |
connect.static options.base | |
] | |
grunt.loadNpmTasks 'grunt-contrib-coffee' | |
grunt.loadNpmTasks 'grunt-contrib-uglify' | |
grunt.loadNpmTasks 'grunt-contrib-stylus' | |
grunt.loadNpmTasks 'grunt-contrib-cssmin' | |
grunt.loadNpmTasks 'grunt-ember-templates' | |
grunt.loadNpmTasks 'grunt-contrib-concat' | |
grunt.loadNpmTasks 'grunt-commonjs' | |
grunt.loadNpmTasks 'grunt-contrib-clean' | |
grunt.loadNpmTasks 'grunt-contrib-watch' | |
grunt.loadNpmTasks 'grunt-contrib-qunit' | |
grunt.loadNpmTasks 'grunt-contrib-copy' | |
grunt.loadNpmTasks 'grunt-contrib-connect' | |
grunt.registerTask 'default', [ | |
'clean' | |
'coffee' | |
'commonjs:modules' | |
'stylus' | |
'emberTemplates' | |
'concat:scripts' | |
'concat:styles' | |
'copy:static' | |
] | |
grunt.registerTask 'server', [ | |
'default' | |
'connect:server:keepalive' | |
] | |
grunt.registerTask 'dev', [ | |
'default' | |
'connect:server' | |
'watch' | |
] | |
grunt.registerTask 'precompile', [ | |
'clean' | |
'coffee' | |
'commonjs' | |
'stylus' | |
'emberTemplates' | |
'concat:precompile' | |
'concat:styles' | |
'uglify' | |
'cssmin' | |
] | |
grunt.registerTask 'test', [ | |
'default' | |
'commonjs:fixtures' | |
'concat:tests' | |
'qunit' | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment