Created
February 28, 2020 22:05
-
-
Save binyamin/c10cbbf5eb622579f1676c2c3df7a5ef to your computer and use it in GitHub Desktop.
Gulp setup with sass and livereload
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
const gulp = require('gulp'); | |
const browserSync = require('browser-sync').create(); | |
const sass = require('gulp-sass'); | |
const rename = require('gulp-rename'); | |
const sourcemaps = require('gulp-sourcemaps'); | |
const postcss = require('gulp-postcss') | |
const css = cb => { | |
gulp.src('./css/style.scss') | |
.pipe(sourcemaps.init()) | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(rename('style.min.css')) | |
.pipe(postcss([ | |
require('autoprefixer'), | |
require('cssnano') | |
])) | |
.pipe(sourcemaps.write('.')) | |
.pipe(gulp.dest('./css')) | |
.pipe(browserSync.stream()) | |
cb(); | |
} | |
const serve = cb => { | |
browserSync.init({ | |
server: "./", | |
open: false, | |
port: 8080 | |
}) | |
gulp.watch('./css/**/*.scss', css); | |
gulp.watch('index.html').on('change', browserSync.reload); | |
gulp.watch('./js/**/*.js').on('change', browserSync.reload); | |
cb(); | |
} | |
exports.default = serve; | |
exports.pack = css; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment