Last active
October 31, 2021 23:36
-
-
Save htr3n/eb8dde0659b066367d438879d6650e54 to your computer and use it in GitHub Desktop.
Gulp 4 configuration SASS, PostCSS, autoprefixer, cssnano, sourcemaps
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
const gulp = require('gulp'); | |
const sass = require('gulp-sass'); | |
const postcss = require('gulp-postcss'); | |
const autoprefixer = require('autoprefixer'); | |
const cssnano = require('cssnano'); | |
const sourcemaps = require('gulp-sourcemaps'); | |
const log = require('fancy-log'); | |
const sassSourceFile = 'assets/scss/hyde-hyde.scss'; | |
const outputFolder = 'static/css'; | |
const watchedResources = 'assets/scss/**/*'; | |
gulp.task('scss', function (done) { | |
gulp.src(sassSourceFile) | |
.pipe(sourcemaps.init()) | |
.pipe(sass().on('error', function(err){ | |
log.error(err.message); | |
})) | |
.pipe(postcss([autoprefixer, cssnano])) | |
.pipe(sourcemaps.write('.')) | |
.pipe(gulp.dest(outputFolder)) | |
.on('end', done); | |
}); | |
gulp.task('watch', gulp.series('scss', function (done) { | |
gulp.watch(watchedResources, gulp.parallel('scss')); | |
done(); | |
})); | |
gulp.task('default', gulp.series('watch', function () {})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cssnano() instaed of cssnano