Last active
February 16, 2018 17:50
-
-
Save tlinkner/b689a55421d3595edaa6 to your computer and use it in GitHub Desktop.
Grunt LiveReload with SASS and Local Server
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
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']); | |
} |
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": "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