gsm

gulp-style-modules

A gulp plugin for wrapping css into style modules as used by Polymer

Showing:

Popularity

Downloads/wk

306

GitHub Stars

24

Maintenance

Last Commit

6yrs ago

Contributors

0

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

gulp-style-modules

A gulp plugin for wrapping css files into style modules as used by Polymer

Install

$ npm install --save-dev gulp-style-modules

Examples

var stylemod = require('gulp-style-modules');

// Wrap css files
gulp.task("modularize-styles", function() {
    gulp.src("./src/**/*.css")
        .pipe(stylemod({
            // All files will be named 'styles.html'
            filename: "styles",
            // Use '-css' suffix instead of '-styles' for module ids
            moduleId: function(file) {
                return path.basename(file.path, path.extname(file.path)) + "-css";
            }
        }))
        .pipe(gulp.dest("./src"));
}

// Use with preprocessor (e.g. stylus)
gulp.task("modularize-styles", function() {
    gulp.src("./src/**/*.styl")
        .pipe(stylus({use: [nib()]}))
        .pipe(stylemod())
        .pipe(gulp.dest("./src"));
}

Options / Defaults

{
    // string / function to be used for file names. Can be either a fixed string or a function
    // that takes a [vinyl](https://github.com/gulpjs/vinyl) file object and returns a string
    filename: function(file) {
        return path.basename(file.path, path.extname(file.path)) + "-styles";
    },
    // string / function to be used for module ids. Can be either a fixed string or a function
    // that takes a [vinyl](https://github.com/gulpjs/vinyl) file object and returns a string
    moduleId: function(file) {
        return path.basename(file.path, path.extname(file.path)) + "-styles";
    }
}

LICENSE MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial