Skip to content

Instantly share code, notes, and snippets.

@tlinkner
Last active February 16, 2018 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tlinkner/b689a55421d3595edaa6 to your computer and use it in GitHub Desktop.
Save tlinkner/b689a55421d3595edaa6 to your computer and use it in GitHub Desktop.
Grunt LiveReload with SASS and Local Server
module.exports = function (grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Watches for changes in the the specified files and run the task
watch : {
refresh : {
options :{
livereload: '<%= connect.options.livereload %>'
},
files: ['www/**/*.js','www/**/*.scss','www/**/*.css','www/**/*.html'],
tasks: ['sass']
}
},
sass: {
dist: {
options: {
style: 'compact'
},
files: {
'www/css/style.css': 'www/css/style.scss'
}
}
},
// Start a local server
connect : {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from the network
hostname: 'localhost',
base: 'www',
livereload: 35729
},
livereload : {
options: {
open: true
}
}
}
});
// Load node modules
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-sass');
// Register tasks
grunt.registerTask('serve', ['sass','connect:livereload','watch']);
}
{
"name": "test",
"description": "Test project.",
"version": "0.1.0",
"license": "MIT",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-sass": "^0.9.2",
"grunt-contrib-watch": "^0.6.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment