Created
January 28, 2020 09:24
-
-
Save klementj/a07986146d3e53837b48720f3ba88237 to your computer and use it in GitHub Desktop.
Gulpfile for sass webdev projects
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 htmlmin = require("gulp-htmlmin"); | |
| const sass = require("gulp-sass"); | |
| const imagemin = require("gulp-imagemin"); | |
| const uglify = require("gulp-uglify-es").default; | |
| const html = () => | |
| gulp.src("src/index.html") | |
| .pipe(htmlmin({ | |
| collapseWhitespace: true | |
| })) | |
| .pipe(gulp.dest("dist")); | |
| const css = () => | |
| gulp.src("src/index.scss") | |
| .pipe(sass({ | |
| includePaths: ["node_modules"], | |
| outputStyle: 'compressed' | |
| })) | |
| .pipe(gulp.dest("dist")); | |
| const img = () => | |
| gulp.src("src/img/**") | |
| .pipe(imagemin()) | |
| .pipe(gulp.dest("dist/img")); | |
| const js = () => | |
| gulp.src("src/index.js") | |
| .pipe(uglify()) | |
| .pipe(gulp.dest("dist")); | |
| const watch = () => { | |
| gulp.watch("src/**/*.html", html); | |
| gulp.watch("src/**/*.scss", css); | |
| gulp.watch("src/index.js", js); | |
| }; | |
| module.exports = { | |
| default: gulp.parallel(html, css, img, js), | |
| html, | |
| css, | |
| watch, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment