Skip to content

Instantly share code, notes, and snippets.

@hcosta
Created March 10, 2014 18:20
Show Gist options
  • Save hcosta/9470942 to your computer and use it in GitHub Desktop.
Save hcosta/9470942 to your computer and use it in GitHub Desktop.
$ cd project
$ nano package.json
{
"name": "",
"version": "",
"description": "",
"main": "index.html",
"author": "",
"license": "",
"devDependencies": {
"grunt": "~0.4.3",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-connect": "~0.7.1",
"grunt-contrib-sass": "~0.7.3",
"grunt-open": "~0.2.3",
"matchdep": "~0.3.0"
}
}
$ npm install
$ nano Gruntfile
'use strict';
// Gruntfile with the configuration of grunt-express and grunt-open. No livereload yet!
module.exports = function(grunt) {
// Load Grunt tasks declared in the package.json file
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Configure Grunt
grunt.initConfig({
// grunt-express will serve the files from the folders listed in `bases`
// on specified `port` and `hostname`
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
// base: 'app',
livereload: 35729
},
livereload: {
options: {
open: true,
}
}
},
sass: {
dist: {
files: {
'css/style.css' : 'sass/style.scss'
}
}
},
watch: {
sass: {
files: '**/*.scss',
tasks: ['sass']
},
css: {
files: '**/*.css',
options: {
livereload: true
}
},
html: {
files: ['**/*.html'],
options: {
livereload: true
}
}
},
// grunt-open will open your browser at the project's URL
open: {
all: {
// Gets the port from the connect configuration
path: 'http://localhost:9000'
}
}
});
// Creates the `server` task
grunt.registerTask('server', [
'connect:livereload',
'open',
'watch'
]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment