Skip to content

Instantly share code, notes, and snippets.

@jdsteinbach
Created February 14, 2015 04:43
Show Gist options
  • Select an option

  • Save jdsteinbach/1001c1c133d62c9be5a5 to your computer and use it in GitHub Desktop.

Select an option

Save jdsteinbach/1001c1c133d62c9be5a5 to your computer and use it in GitHub Desktop.
Grunt: Node-Sass, AutoPrefixer, serve & watch
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
options: {
sourceMap: true,
outputStyle: 'expanded'
},
dist: {
files: [
{
expand: true,
cwd: "sass",
src: ["**/*.scss"],
dest: "css",
ext: ".css"
}
]
}
},
autoprefixer: {
options: {
browsers: [
'last 3 versions'
],
map: true
},
dist: {
files: [
{
expand: true,
cwd: "css",
src: ["**/*.css"],
dest: "css",
ext: ".css"
}
]
}
},
watch: {
gruntfile: {
files: ['Gruntfile.js']
},
scss: {
files: '**/*.scss',
tasks: ['sass', 'autoprefixer']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'{,*/}*.html',
'{,*/}*.php',
'js/{,*/}*.js',
'css/{,*/}*.css',
'sass/{,*/}*.scss',
'images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
},
},
connect: {
options: {
port: 9000,
open: true,
livereload: 35729,
// Change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
open: true
}
},
dist: {
options: {
base: '~/<%= pkg.name %>'
}
}
}
});
// Load these required NPM tasks:
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('serve', function (target) {
grunt.task.run([
'connect:livereload',
'watch'
]);
});
grunt.registerTask('default', ['serve']);
};
{
"name": "james-steinbach",
"version": "0.0.1",
"description": "Build process for simple site",
"author": "James Steinbach",
"devDependencies": {
"grunt": "0.4.5",
"grunt-sass": "^0.18.0",
"grunt-autoprefixer": "^2.2.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-watch": "^0.6.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment