Coder Social home page Coder Social logo

jsorrell / gulp-watch-sass Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sp00m/gulp-watch-sass

0.0 1.0 0.0 182 KB

Watches for SASS files modifications, taking @import-ing SASS files into account.

License: MIT License

JavaScript 100.00%

gulp-watch-sass's Introduction

gulp-watch-sass

Watches for SASS files modifications thanks to gulp-watch, while adding @importing SASS files to the stream thanks to gulp-fn.

State

master: Build Coverage

develop: Build Coverage

Dependencies Vulnerabilities License

Install

npm install --save-dev gulp-watch-sass

Usage

const gulp = require("gulp")
const sass = require("gulp-sass")
const watchSass = require("gulp-watch-sass")

gulp.task("sass:watch", () => watchSass([
  "./public/**/*.{scss,css}",
  "!./public/libs/**/*"
])
  .pipe(sass())
  .pipe(gulp.dest("./public")));

API

watchSass(glob, [options])

Creates a watcher that will spy on files that are matched by glob which can be a glob string or array of glob strings. On file change, the modified file and the @importing files will be added to the stream.

You can watch for CSS files modifications in addition to SASS ones. In this case, if the modified file is a CSS file, then only the @importing files will be added to the stream.

options

This object is passed to the gulp-watch options directly.

options.includePaths

Mimics node-sass' includePaths option.

Why?

gulp.watch recompiles all the SASS files:

gulp.task("sass", () => gulp.src([
  "./public/**/*.scss",
  "!./public/libs/**/*"
])
  .pipe(sass())
  .pipe(gulp.dest("./public")));

gulp.task("sass:watch", () => {
  gulp.watch([
    "./public/**/*.scss",
    "!./public/libs/**/*"
  ], ["sass"]);
});

This works well, but each time a SASS file is updated, all the project's SASS files are recompiled, which can be quite long when working on big projects.

gulp-watch doesn't take @importing files into account:

gulp.task("sass:watch", () => watch([
  "./public/**/*.scss",
  "!./public/libs/**/*"
])
  .pipe(sass())
  .pipe(gulp.dest("./public")));

This recompiles only modified SASS files, but because @import statements are not resolved, the stylesheets may not be refreshed as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.