Skip to content

Instantly share code, notes, and snippets.

@jamesflorentino
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesflorentino/a6f03349553ca6e8bb36 to your computer and use it in GitHub Desktop.
Save jamesflorentino/a6f03349553ca6e8bb36 to your computer and use it in GitHub Desktop.
My solution to enabling livereload with connect-assets.
// to be used in jade
app.set('dev', app.get('env') === 'development');
// to be used as temporary folder
app.use('/tmp', express.static(__dirname + '/.tmp'));
module.exports = function(grunt) {
grunt.initConfig({
watch: {
stylus: {
files: ['assets/css/**/*.styl'],
tasks: ['stylus']
},
css: {
files: ['.tmp/app.css'],
options: { livereload: true }
}
},
stylus: {
compile: {
options: {
use: [require('nib')]
},
files: [ {'.tmp/app.css': 'assets/css/app.styl'} ]
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.registerTask('default', ['stylus', 'watch']);
};
html
head
if local.settings.dev
link(href='/tmp/app.css', rel='stylesheet')
script(src="//localhost:35729/livereload.js")
else
!= css('app')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment