Using these files, you can quickly configure the build of your project on Gulp.
- gulp-sass - compilation of SASS, SCSS into CSS;
- Browsersync - browser auto-refresh;
- gulp-autoprefixer - automatically arranges vendor prefixes in CSS in accordance with the Can I Use service;
- clean-css - CSS optimizer;
- gulp-concat - file concatenation;
- gulp-sourcemaps - creating sourcemaps;
- gulp-uglify - Minify JavaScript;
- del - Delete files and directories using globs;
Install Node JS
Install Git
Open cmd
on Windows or Terminal
on Linux/MacOS and follow next steps:
- install
gulp
globally -npm install --global gulp-cli
- download build -
git clone https://github.com/alexhamenko/gulp-4-sass
- go to the project folder -
cd gulp-4-sass
- install packages from package.json -
npm i
- run
gulp
command to make sure everything is installed correctly
./src
/css
/main.scss /media.scss
/js
/lib.js /main.js
./gulpfile.js
./package.json
./index.html
main.scss
, media.scss
, lib.js
and main.js
- these files are used for verifying the correct work of the build. To use your own file, add it to the src/css
or src/js
folder and edit correct the corresponding lines in the cssFiles
and jsFiles
variables fromgulpfile.js
.
If you want to use LESS or Stylus preprocessors instead of SASS, do the following steps after downloading this project:
- Go to the project folder -
cd gulp-4-sass
- Run command
npm i
- Run command
npm i -SD gulp-less
- Run command
npm uninstall gulp-sass -SD
- Change extensions of style files from
scss
toless
in thesrc/css
folder - Replace SCSS code with LESS code in the style files from
src/css
folder - Edit gulpfile.js:
- change
const sass = require('gulp-sass');
toconst less = require('gulp-less');
- change files extensions from
scss
toless
in theconst cssFiles
- change
.pipe(sass())
to the.pipe(less())
in thestyles()
function - change
gulp.watch('./src/css/**/*.sass', styles);
to thegulp.watch('./src/css/**/*.less', styles);
in thewatch()
function - delete
gulp.watch('./src/css/**/*.scss', styles);
- change
- Go to the project folder -
cd gulp-4-sass
- Run command
npm i
- Run command
npm i -SD gulp-stylus
- Run command
npm uninstall -SD gulp-sass
- Change extensions of style files from
scss
tostyl
in thesrc/css
folder - Replace SCSS code with Stylus code in the style files from
src/css
folder - Edit gulpfile.js:
- change
const sass = require('gulp-sass');
toconst stylus = require('gulp-stylus');
- change file's extensions from
scss
tostyl
in theconst cssFiles
- change
.pipe(sass())
to.pipe(stylus())
in thestyles()
function - change
gulp.watch('./src/css/**/*.sass', styles);
to thegulp.watch('./src/css/**/*.styl', styles);
in thewatch()
function - delete
gulp.watch('./src/css/**/*.scss', styles);
- change
Based on this build