Created
December 19, 2013 11:25
-
-
Save psi-4ward/8037802 to your computer and use it in GitHub Desktop.
Grunt + LiveReload + LESS + Contao
Be sure to have LiveReload Chrome Extension installed
This file contains hidden or 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 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) { | |
var dir = grunt.option('dir'); | |
if(!dir) { | |
grunt.fail.fatal('Error: no watching directory specified! Use --dir option.', 1); | |
} | |
grunt.log.ok('Watching directory: ' + dir); | |
// load all grunt tasks | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
var cfg = {}; | |
// On demand | |
cfg.watch = { | |
less: { | |
files: [dir + '/**/*.less'], | |
tasks: ['less'] | |
}, | |
css: { | |
files: [dir + '/**/*.css'], | |
options: { | |
livereload: true | |
} | |
} | |
}; | |
// LESS | |
// running `grunt less` will compile once | |
cfg.less = { | |
dev: { | |
options: { | |
paths: [dir + "/**/*.less"], | |
yuicompress: false | |
}, | |
files: {} | |
} | |
}; | |
cfg.less.dev.files[dir + "/style.css"] = dir+"/less/style.less"; | |
// init grunt with the config | |
grunt.initConfig(cfg); | |
// register server task | |
grunt.registerTask('default', [ | |
// 'connect', | |
'watch' | |
]); | |
}; |
This file contains hidden or 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
{ | |
"name": "contao_livereload", | |
"version": "0.0.0", | |
"description": "Grunt based LiveReload for Contao", | |
"dependencies": {}, | |
"devDependencies": { | |
"grunt": "~0.4.2", | |
"grunt-contrib-less": "~0.8.3", | |
"grunt-contrib-watch": "~0.5.3" | |
}, | |
"author": "Christoph Wiechert", | |
"license": "GPL" | |
} |
This file contains hidden or 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
#!/bin/bash | |
GRUNTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
DIR=$1 | |
if [ "$DIR" == "" ] | |
then | |
DIR=. | |
fi | |
DIR=`realpath $DIR` | |
grunt --gruntfile $GRUNTDIR/Gruntfile.js --dir $DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment