Created
June 6, 2019 19:10
-
-
Save jonobr1/7b11c205d12db8890d61e41c1df91b49 to your computer and use it in GitHub Desktop.
A Simple Gulp File to Serve Static HTML5 Sites
This file contains 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
/** | |
* npm install gulp | |
* npm install gulp-less | |
* npm install fancy-log | |
* npm install browser-sync | |
* gulp # This will watch and serve at http://localhost:3000 | |
*/ | |
var gulp = require('gulp'); | |
var less = require('gulp-less'); | |
var log = require('fancy-log'); | |
var browserSync = require('browser-sync').create(); | |
function css(callback) { | |
gulp.src('./styles/*.less') | |
.pipe(less().on('error', log.error)) | |
.pipe(gulp.dest('./styles')); | |
browserSync.reload(); | |
if (callback) { | |
callback(); | |
} | |
} | |
function html(callback) { | |
browserSync.reload(); | |
if (callback) { | |
callback(); | |
} | |
} | |
function watch(callback) { | |
browserSync.init({ | |
ui: false, | |
server: { | |
baseDir: './' | |
} | |
}); | |
gulp.watch('./styles/*.less', css); | |
gulp.watch('./*.html', html); | |
if (callback) { | |
callback(); | |
} | |
} | |
exports.default = gulp.series(css, watch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment