All Projects → Mister-Hope → gulp-sass

Mister-Hope / gulp-sass

Licence: MIT license
Sass plugin for gulp

Programming Languages

typescript
32286 projects
SCSS
7915 projects
javascript
184084 projects - #8 most used programming language
Sass
350 projects

Projects that are alternatives of or similar to gulp-sass

sass-starter-pack
Sass starter files using Gulp v4.0.0 🔥
Stars: ✭ 34 (-2.86%)
Mutual labels:  gulp, gulp-sass
gulp-tmod
grunt-tmod gulp version
Stars: ✭ 30 (-14.29%)
Mutual labels:  gulp
streetsupport-web
Helping people facing homelessness across the UK to find services in their area, and connecting people who want to help to where it is needed most.
Stars: ✭ 21 (-40%)
Mutual labels:  gulp
envoyer-npm-deployment
Compile assets that depend on node packages using Laravel Envoyer deployment hooks
Stars: ✭ 43 (+22.86%)
Mutual labels:  gulp
bibleapi-rest
Node.js based Bible API RESTful web service
Stars: ✭ 34 (-2.86%)
Mutual labels:  gulp
gulp-boilerplate
🚀 A opinionated gulp boilerplate for individuals and teams
Stars: ✭ 18 (-48.57%)
Mutual labels:  gulp
file-include-webpack-plugin
A webpack plugin to include files using @@ include syntax in html files, like gulp-file-include
Stars: ✭ 16 (-54.29%)
Mutual labels:  gulp
seezoon-framework-all
Seezoon快速开发平台基于spring mybatis shiro jquery 完全的前后端分离的后台管理系统,采用最简单技术,实现快速开发.
Stars: ✭ 47 (+34.29%)
Mutual labels:  gulp
WordPress-UIkit-Starter-Theme
A WordPress starter theme for developers using the frontend framework UIkit
Stars: ✭ 55 (+57.14%)
Mutual labels:  gulp
eadmin
eadmin - 极致用户体验与极简开发并存的开箱即用的后台UI框架
Stars: ✭ 258 (+637.14%)
Mutual labels:  gulp
fly-helper
It's a Tool library, method collection
Stars: ✭ 21 (-40%)
Mutual labels:  gulp
manage-demo
后台管理系统模版
Stars: ✭ 19 (-45.71%)
Mutual labels:  gulp
sp-build-tasks
👷 SharePoint front-end projects automation and tasks tool-belt
Stars: ✭ 15 (-57.14%)
Mutual labels:  gulp
generator-veams
Scaffold modern frontend web apps or web pages with a static site generator (Assemble or Mangony), Grunt and/or Gulp, Sass and Bower. Use modern frameworks like Bourbon, Bootstrap or Foundation and structure your JavaScript with ES Harmony support.
Stars: ✭ 45 (+28.57%)
Mutual labels:  gulp
licaibao-responsive
一个响应式的理财网站,主要是为了学习响应式页面设计而制作。
Stars: ✭ 26 (-25.71%)
Mutual labels:  gulp
electron-angular-ngrx
An Angular (6x) Electron seed featuring @angular/cli, @ngrx/platform, and Typescript. Complete with HMR workflow
Stars: ✭ 39 (+11.43%)
Mutual labels:  gulp
pacco
A bundler for modular and extensible web projects.
Stars: ✭ 16 (-54.29%)
Mutual labels:  gulp
react-ssr-spa
Server side rendered single page app using reactjs official libraries.
Stars: ✭ 30 (-14.29%)
Mutual labels:  gulp
Crashlyzer
Crash viewer web application for displaying the crashes reported by rn-crash-reporter components from React Native mobile applications.
Stars: ✭ 59 (+68.57%)
Mutual labels:  gulp
angular-material-boilerplate
A straightforward and well structured boilerplate based on Google's Angular Material project.
Stars: ✭ 28 (-20%)
Mutual labels:  gulp

@mr-hope/gulp-sass

CodeQL Test and coverage codecov

Sass plugin for gulp.

Migrating to V3

Since sass introduce a new compile api in V1 (which use Promise instead of callback when async), we are upgrading to V3 to use this new API.

So V3 requireds a minimum sass version of 1.45.0.

Due to sync is faster than async, users should use sync as the first choise, we marked async ones with Async prefix in V3.

So we are providing:

  • The legacy apis legacy and legacyAsync (used to be sassSync and sass ).
  • New compile api sass and sassAsync
  • Option types LegacySassOptions and LegacySassAsyncOptions for old apis, together with SassAsyncOptions and SassOptions for new apis.
  • Function types GulpSass, GulpSassAsync, LegacyGulpSass, LegacyGulpSassAsync for sass, sassAsync, legacy, legacyAsync

Compare

We strongly recommend you to use this plugin instead of gulp-sass or gulp-dart-sass.

Why

gulp-sass

gulp-sass is still using node-sass by default, and it has been deprecated for quite a long while.

Also, node-sass will take a long time to built during installation.

gulp-dart-sass

gulp-dart-sass is just forking the above project and changed it's deps, while it:

  • just remove sourcemap and pipe tests
  • still remain the old deps

@mr-hope/gulp-sass

It's a totally rewrite version in typescript. It has:

  • Uses new compile api
  • Option interface, and will provide autocomplete and validate (with IDE support like VSCode)
  • Code quality test and 100% test coverage

Install

yarn add -D @mr-hope/gulp-sass

or

npm i -D @mr-hope/gulp-sass

Basic Usage

You should use sass to synchronously tranform your sass code in to css:

const { dest, src, watch } = require("gulp");
const { sass } = require("@mr-hope/gulp-sass");

const build = src("./styles/**/*.scss")
  .pipe(sass().on("error", sass.logError))
  .pipe(dest("./css"));

exports.build = build;
exports.watch = watch("./styles/**/*.scss", build);

You can also compile asynchronously:

const { dest, src, watch } = require("gulp");
const { sassAsync } = require("@mr-hope/gulp-sass");

const build = src("./styles/**/*.scss")
  .pipe(sassAsync().on("error", sassAsync.logError))
  .pipe(dest("./css"));

exports.build = build;
exports.watch = watch("./styles/**/*.scss", build);

Error logging

Note that we provide a useful function called logError on these 2 tranform functions to let you print errors gracefully.

See the demo above for usage.

Performance

Note that synchronous compilation is twice as fast as asynchronous compilation by default, due to the overhead of asynchronous callbacks. To avoid this overhead, you can use the fibers package to call asynchronous importers from the synchronous code path. To enable this, pass the Fiber class to the fiber option:

const { dest, src, watch } = require("gulp");
const { sass } = require("@mr-hope/gulp-sass");
const fiber = require("fibers");

const build = src("./styles/**/*.scss")
  .pipe(sass({ fiber }).on("error", sass.logError))
  .pipe(dest("./css"));

exports.build = build;
exports.watch = watch("./styles/**/*.scss", build);

Options

You should pass in options just like you would for Dart Sass compileString api. They will be passed along just as if you were using sass. We also export SassOption and SassAsyncOption interface in declaration files.

For example:

exports.build = src("./styles/**/*.scss")
  .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
  .pipe(dest("./css"));

Or this for asynchronous code:

exports.build = src("./styles/**/*.scss")
  .pipe(
    sassAsync({ outputStyle: "compressed" }).on("error", sassAsync.logError)
  )
  .pipe(dest("./css"));

Source Maps

@mr-hope/gulp-sass can be used in tandem with gulp-sourcemaps to generate source maps for the Sass to CSS compilation. You will need to initialize gulp-sourcemaps prior to running @mr-hope/gulp-sass and write the source maps after.

const sourcemaps = require("gulp-sourcemaps");

exports.build = src("./styles/**/*.scss")
  .pipe(sourcemaps.init())
  .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
  .pipe(sourcemaps.write())
  .pipe(dest("./css"));

By default, gulp-sourcemaps writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a path relative to the gulp.dest() destination in the sourcemaps.write() function.

const sourcemaps = require("gulp-sourcemaps");

exports.build = src("./styles/**/*.scss")
  .pipe(sourcemaps.init())
  .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
  .pipe(sourcemaps.write("./maps"))
  .pipe(dest("./css"));

Node Support

Only Active LTS and Current releases are supported.

Legacy APIS

Usage

You should use legacy to synchronously tranform your sass code in to css:

const { dest, src, watch } = require("gulp");
const { legacy } = require("@mr-hope/gulp-sass");

const build = src("./styles/**/*.scss")
  .pipe(legacy().on("error", legacy.logError))
  .pipe(dest("./css"));

exports.build = build;
exports.watch = watch("./styles/**/*.scss", build);

You can also compile asynchronously:

const { dest, src, watch } = require("gulp");
const { legacyAsync } = require("@mr-hope/gulp-sass");

const build = src("./styles/**/*.scss")
  .pipe(legacyAsync().on("error", legacyAsync.logError))
  .pipe(dest("./css"));

exports.build = build;
exports.watch = watch("./styles/**/*.scss", build);

Error logging

Note that we provide a useful function called logError on these 2 tranform functions to let you print errors gracefully.

See the demo above for usage.

Performance

Note that synchronous compilation is twice as fast as asynchronous compilation by default, due to the overhead of asynchronous callbacks. To avoid this overhead, you can use the fibers package to call asynchronous importers from the synchronous code path. To enable this, pass the Fiber class to the fiber option:

const { dest, src, watch } = require("gulp");
const { legacyAsync } = require("@mr-hope/gulp-sass");
const fiber = require("fibers");

const build = src("./styles/**/*.scss")
  .pipe(legacyAsync({ fiber }).on("error", legacyAsync.logError))
  .pipe(dest("./css"));

exports.build = build;
exports.watch = watch("./styles/**/*.scss", build);

Options

You should pass in options just like you would for Dart Sass. They will be passed along just as if you were using sass. We also export LegacySassOption and LegacySassAsyncOption interface in declaration files.

LegacySassOption and LegacySassAsyncOption is just like LegacyOptions<'sync'> and LegacyOptions<'async'> in sass except for the data and file options which are used by @mr-hope/gulp-sass internally.

For example:

exports.build = src("./styles/**/*.scss")
  .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
  .pipe(dest("./css"));

Or this for asynchronous code:

exports.build = src("./styles/**/*.scss")
  .pipe(
    sassAsync({ outputStyle: "compressed" }).on("error", sassAsync.logError)
  )
  .pipe(dest("./css"));

Source Maps

@mr-hope/gulp-sass can be used in tandem with gulp-sourcemaps to generate source maps for the Sass to CSS compilation. You will need to initialize gulp-sourcemaps prior to running @mr-hope/gulp-sass and write the source maps after.

const sourcemaps = require("gulp-sourcemaps");

exports.build = src("./styles/**/*.scss")
  .pipe(sourcemaps.init())
  .pipe(legacy({ outputStyle: "compressed" }).on("error", legacy.logError))
  .pipe(sourcemaps.write())
  .pipe(dest("./css"));

By default, gulp-sourcemaps writes the source maps inline in the compiled CSS files. To write them to a separate file, specify a path relative to the gulp.dest() destination in the sourcemaps.write() function.

const sourcemaps = require("gulp-sourcemaps");

exports.build = src("./styles/**/*.scss")
  .pipe(sourcemaps.init())
  .pipe(legacy({ outputStyle: "compressed" }).on("error", legacy.logError))
  .pipe(sourcemaps.write("./maps"))
  .pipe(dest("./css"));

Issues

@mr-hope/gulp-sass is a very light-weight wrapper around Dart Sass. Because of this, the issue you're having likely isn't a @mr-hope/gulp-sass issue, but an issue with one those projects or with Sass as a whole.

If you have a feature request/question how Sass works/concerns on how your Sass gets compiled/errors in your compiling, it's likely a Dart Sass issue and you should file your issue with one of those projects.

If you're having problems with the options you're passing in, it's likely a Dart Sass and you should file your issue with one of those projects.

We may, in the course of resolving issues, direct you to one of these other projects. If we do so, please follow up by searching that project's issue queue (both open and closed) for your problem and, if it doesn't exist, filing an issue with them.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].