This repository was archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson 11 - Powerful builds #17
Copy link
Copy link
Open
Labels
Description
Gulp : getting started
- Gulp creates a stream of the files to process, meaning less I/O operations, and run task in parallel.
Using Gulp with Sass
Ex of gulpfile.js:
const gulp = require("gulp");
const sass = require("gulp-sass");
gulp.task('default', function() {
console.log("Running the default");
}
gulp.task('styles', function() {
gulp.src('sass/**/*.scss') //read all files in the sass folder and subfolders
.pipe(sass()) //stream the source files read and convert the scss into css
.pipe(gulp.dest('./css')) //put all the css files generated into the css folder
;
}Using Gulp with autoprefixer
Install the autoprefixer plugin: https://www.npmjs.com/package/gulp-autoprefixer
...
const autoprefixer = require("gulp-autoprefixer");
...
gulp.task('styles', function() {
gulp.src('sass/**/*.scss') //read all files in the sass folder and subfolders
.pipe(sass()) //stream the source files read and convert the scss into css
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('./css')) //put all the css files generated into the css folder
;
}Setup a gulp watch
gulp.task('default', function() {
gulp.watch('sass/**/*.scss', ['styles']); //see styles task above
}Reactions are currently unavailable