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

gulp-globber

v1.1.1

Published

Allow gulp-sass to utilize globbing to compile partials

Downloads

30

Readme

Gulp-Globber

gulp-globber gives you the power to do globbing imports for gulp-sass. On its own gulp-sass does not allow you to import scss partials using globbing but with gulp-globber you can import an entire directories!

Some things to note:

  • We cannot guarantee the order of the imports at a file level.

Version

1.1.1

Installation

Use the following command:

$ npm install --save-dev gulp-globber

Basic Usage

Create a single scss file that you will use as the main scss to hold all of your imports. It can be empty or it can hold already predefined imports

main.scss file Before:

// test_app/css/sass/main.scss
@import "partials/partial/model.scss";

When used by itself gulp-globber will generate a new scss file which will have all the imports dictated by the source.

var globber = require('gulp-globber');
var gulp    = require('gulp');

var ROOT = 'test_app/';

gulp.task('glob', function(){
    return gulp.src(ROOT + 'css/sass/main.scss')
        .pipe(globber({
            // This is a required field that points 
            // to folder containing all the scss partials
            source  : ROOT + 'css/sass/other_partials'
        }))
        .pipe(gulp.dest(ROOT + '/css/sass'))
});
// test_app/css/sass/_main.scss
@import "partials/partial/model.scss";

/* ---- Auto-Generated Content Below ---- */
@import "test_app/css/sass/other_partials/test.scss";
@import "test_app/css/sass/other_partials/temp.scss";
@import "test_app/css/sass/other_partials/sub_partials/mixins.scss";

We can control the order of the imports from a folder level but we cannot guarantee the order of the individual scss files within each folder. To give yourself more control over the imports of the folders you can pass an array of directories and they will import in the order they appear in the array.

var globber = require('gulp-globber');
var gulp    = require('gulp');
var ROOT    = 'test_app/';

gulp.task('glob1', function(){
    return gulp.src(ROOT + 'css/sass/main.scss')
        //  All the files under this directory will 
        // show up first in the import list
        .pipe(globber([ ROOT + 'css/scss/other_partials', ROOT + 'views/scss/some_other_partials']))
        
        .pipe(gulp.dest(ROOT + '/css/sass')) // final output will be a file named _main.scss
});

// This is the same as the task glob1
gulp.task('glob2', function(){
    return gulp.src(ROOT + 'css/sass/main.scss')
        //  All the files under this directory will 
        // show up first in the import list
        .pipe(globber({
            source: [ ROOT + 'css/scss/other_partials', ROOT + 'views/scss/some_other_partials']
        }))
        
        .pipe(gulp.dest(ROOT + '/css/sass')) // final output will be a file named main.scss
});

// This is also the same as task glob1 & glob2 except the name of the output file will be a little longer
gulp.task('glob', function(){
    return gulp.src(ROOT + 'css/sass/main.scss')
        //  All the files under this directory will 
        // show up first in the import list
        .pipe(globber(ROOT + 'css/scss/other_partials')) 
        .pipe(globber(ROOT + 'views/scss/some_other_partials')) 

        .pipe(gulp.dest(ROOT + '/css/sass')) // final output will be a file named main.scss
});

You can optionally rename given file and you uses gulp-sass to compile your scss file

var globber = require('gulp-globber');
var gulp    = require('gulp');
var sass    = require('gulp-sass');
var ROOT    = 'test_app/';

gulp.task('glob1', function(){
    return gulp.src(ROOT + 'css/sass/main.scss')
        //  All the files under this directory will 
        // show up first in the import list
        .pipe(globber({ 
            source: [ ROOT + 'css/scss/other_partials', ROOT + 'views/scss/some_other_partials'],
            rename: 'combined.scss'
        }))
        .pipe(sass()) // Compile the passed in file combined.scss
        .pipe(gulp.dest(ROOT + '/css/')) // final output will be a file named combined.css
});

Options

options.source (Required)

Type : String | Array Default : none

Specify the directories from which you want to import your scss files.

options.exclude

Type : Array Default : ['!*.scss']

For each of the specified sources the plugin will exclude the files dictated by this option. By default, this plugin will exclude all files except .scss

options.rename

Type : String Default : none

Renames the output file to a name of your choosing

Todos

  • Write Tests

License

Copyright (c) <2016>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.