Skip to content

Instantly share code, notes, and snippets.

@logeshpaul
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save logeshpaul/a1a42048a257fbd8a254 to your computer and use it in GitHub Desktop.
Save logeshpaul/a1a42048a257fbd8a254 to your computer and use it in GitHub Desktop.
Gulp + Sass + Browser Sync
/* Require */
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
gulp.task('sass', function(){
gulp.src('style/scss/styles.scss')
.pipe(sass({inlcludePaths: ['scss']}))
.pipe(gulp.dest('style/css'));
});
gulp.task('browser-sync', function() {
browserSync.init(["style/css/*.css", "script/js/*.js"], {
server: {
baseDir: "./"
}
});
});
gulp.task('default', ['sass', 'browser-sync'], function () {
gulp.watch("style/scss/*.scss", ['sass']);
});

Prerequisites

Before starting, you should have:

A project containing at least an index.html & some scss files. NodeJS installed. GulpJS installed globally 'npm install -g gulp'

Step 1 - Install We need to install 3 tools locally to our project - gulp, gulp-sass & browser-sync. In your terminal/command line, navigate to your project directory and run

npm install gulp gulp-sass browser-sync

Step 2 - File creation

create a file named gulpfile.js

Step 3 - Start the server

Type gulp to trigger the server gulp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment