npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ideasonpurpose/gulp-task-styles

v0.1.2

Published

A gulp 4 task for compiling stylesheets with Sass and PostCSS

Downloads

2

Readme

dependencies Status code style: prettier

Gulp Task: Styles

Create pre-configured Gulp 4 tasks using Sass and PostCSS to generate CSS stylesheets.

Installation

$ yarn add @ideasonpurpose/gulp-task-styles

  or

$ npm install @ideasonpurpose/gulp-task-styles

Usage

Basic

Call the create method directly on the import. In most cases, just trust the defaults and go:

// Call `create` on the require to initialize a new task
const sass = require("@ideasonpurpose/gulp-task-styles").create();

// Export to make the task publicly callable
exports.sass = sass;

Custom options

The create method accepts one configuration object. This module accepts four properties:

  • src
    A glob string or array of glob-strings. Defaults to src/sass/**/* Passed directly to gulp.src

  • srcOptions
    An object containing any [options][srcoptions] recognized by [gulp.src][] string or array of glob-strings. All options are passed directly to gulp-src except for since.

    • srcOptions.since
      To use incremental builds, set the value of since to true. This will be replaced with gulp.lastRun in the generated function. (The gulp instance will also need to be included, see gulp below)
  • dest
    The output path to be passed to gulp.dest Defaults to dist/css Passed directly to gulp.dest

  • sassConfig
    A Sass configuration object of settings to pass to gulp-sass (and then to node-sass). See Sass Config below for default settings. Passed directly to gulp-sass

  • postcssPlugins
    An array of plugins to pass to gulp-postcss. This array completely replaces the default set of plugins. See PostCSS Options below for defaults.
    Passed directly to gulp-postcss

  • gulp
    The current gulp instance. Required when srcOptions.since is true

Sass Config

The generated task uses a well-tested set of default Sass settings:

{
  sassConfig: {
    includePaths: ["node_modules"],
    sourceComments: true,
    outputStyle: "expanded"
  }
};

These settings can be overridden by adding a sassOptions key to the configuration object passed to create. Custom settings will be merged with the Sass defaults.

PostCSS Options

The generated task adds a well-tested default set of PostCSS transformations: autoprefixer and postcss-import and, if NODE_ENV is set to production, cssnano for minification and optimization.

{
  postCssPlugins: [
    autoprefixer({ grid: "no-autoplace" }),
    postCssImport(),
    cssnano() // if (NODE_ENV === "production")
  ];
}

As with sassOptions, these settings can be overidden by setting postcssOptions to a new array of plugins. Specifying custom plugins overwrites all defaults postcss plugins including the NODE_ENV environment check.

What about Less?

We don't use it. Pull requests are welcome.

Browserslist

The CSS pipeline uses browserslist definiitons when available. We recommend including a .browserslistrc file in the project root. The task optimizes and minifies the resulting CSS when NODE_ENV is set to production.

Watch helper

Very frequently, gulp watch globs are identical to the source globs for a given task. To reduce repetition, the generated task includes a helper method which calls gulp.watch with default arguments. This makes writing watch tasks very concise and easy to maintain.

For Gulp logging to work correctly withe the watch helper method, the gulp instance must be passed to the create call.

const styles = require("@ideasonpurpose/gulp-task-styles").create({ gulp });

const watch = () => {
  styles.watch(); // calls `gulp.watch(src, {cwd: srcOptions.cwd}, styles)`
};