Last active
April 28, 2016 18:39
-
-
Save carlosbensant/2a3a36633a06a50dda775b2a8bde3958 to your computer and use it in GitHub Desktop.
My Gulpfile using LiveReload + SASS + Sourcemaps + Static-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
'use strict'; | |
const gulp = require('gulp'); | |
const sass = require('gulp-sass'); | |
const sourcemaps = require('gulp-sourcemaps'); | |
const autoprefixer = require('gulp-autoprefixer'); | |
const concat = require('gulp-concat'); | |
const livereload = require('gulp-livereload'); | |
const http = require('http'); | |
const st = require('st'); | |
let inputPath = './assets/scss/**/*.scss'; | |
let outputPath = './public'; | |
let sassOptions = { | |
lineNumbers: true | |
}; | |
gulp.task('sass', () => { | |
return gulp | |
// Find all `.scss` files from the `assets/scss` folder | |
.src(inputPath) | |
.pipe(sourcemaps.init()) | |
.pipe(sass({ | |
outputStyle: 'compressed' | |
}).on('error', sass.logError)) | |
.pipe(autoprefixer({ | |
browsers: ['last 2 versions'], | |
cascade: false | |
})) | |
.pipe(concat('app.min.css')) | |
.pipe(sourcemaps.write('.')) | |
.pipe(gulp.dest(outputPath)) | |
.pipe(livereload()); | |
}); | |
gulp.task('css', () => { | |
return gulp | |
// Find all `.scss` files from the `assets/scss` folder | |
.src(inputPath) | |
.pipe(sass({ | |
outputStyle: 'compressed' | |
}).on('error', sass.logError)) | |
.pipe(concat('app.min.css')) | |
.pipe(gulp.dest(outputPath)) | |
.pipe(livereload()); | |
}); | |
gulp.task('watch', ['server'], function() { | |
livereload.listen({ basePath: '/public' }); | |
gulp.watch(inputPath, ['sass']); | |
}); | |
gulp.task('server', function(done) { | |
http.createServer( | |
st({ | |
path: __dirname + '/public', | |
index: 'index.html', | |
cache: false | |
}) | |
).listen(8080, done); | |
}); | |
gulp.task('default', ['sass', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment