Created
December 16, 2013 14:31
-
-
Save psi-4ward/7987840 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
var buildPath = 'build'; | |
var srcPath = 'src'; | |
var path = require('path'); | |
// # Globbing | |
// for performance reasons we're only matching one level down: | |
// 'test/spec/{,*/}*.js' | |
// use this if you want to recursively match all subfolders: | |
// 'test/spec/**/*.js' | |
module.exports = function(grunt) { | |
// load all grunt tasks | |
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
var cfg = {}; | |
// the Webserver | |
cfg.connect = { | |
all: { | |
options: { | |
port: 9000, | |
hostname: '0.0.0.0', | |
base: buildPath, | |
livereload: true | |
} | |
} | |
}; | |
// On demand | |
cfg.watch = { | |
browserify: { | |
files: [srcPath+'/js/**/*.js'], | |
tasks: ['browserify'] | |
}, | |
less: { | |
files: [srcPath+'/less/*.less'], | |
tasks: ['less'] | |
}, | |
css: { | |
files: [buildPath+'/*.css'], | |
options: { | |
livereload: true | |
} | |
}, | |
js: { | |
files: [buildPath+'/*.js'], | |
options: { | |
livereload: true | |
} | |
}, | |
html: { | |
files: [buildPath+'/*.html'], | |
options: { | |
livereload: true | |
} | |
} | |
}; | |
// Browserify the Javascript | |
cfg.browserify = { | |
dist: { | |
files: {}, // filled later | |
noParse: [ srcPath+'/vendor/**/*' ] | |
} | |
}; | |
cfg.browserify.dist.files[buildPath + '/app.js'] = srcPath + '/js/**/*.js'; | |
// LESS | |
// running `grunt less` will compile once | |
cfg.less = { | |
dev: { | |
options: { | |
paths: [srcPath + "/less/*.less"], | |
yuicompress: false | |
}, | |
files: {} | |
} | |
}; | |
cfg.less.dev.files[buildPath + "/style.css"] = srcPath+"/less/style.less"; | |
// init grunt with the config | |
grunt.initConfig(cfg); | |
// register server task | |
grunt.registerTask('server', [ | |
'browserify', | |
'less', | |
'connect', | |
'watch' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment