Socket
Book a DemoInstallSign in
Socket

postcss-prepend-imports

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-prepend-imports

PostCSS plugin to automatically import global dependencies

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
649
-50.31%
Maintainers
1
Weekly downloads
 
Created
Source

PostCSS Prepend Imports Build Status

PostCSS plugin to automatically import global dependencies.

That's quite useful when you need to preload variables in all css files.

Disclaimer

It's advised to use this plugin in combination with both postcss-import and postcss-custom-properties.

Example using Gulp

gulp.task('css', function() {
    return gulp.src('./src/*.css')
        .pipe(postcss([
            require('postcss-prepend-imports')({
                path: 'shared',
                files: ['color.css']
            }),
            require('postcss-import')(),
            require('postcss-custom-properties')()
        ]))
        .pipe(gulp.dest('./build'));
});

Variables file example

/* ./shared/color.css */
:root {
    --background-default: #ccc;
}

Input

/* ./src/main.css */
.main {
    background: var(--background-default);
}

Output

/* ./build/main.css */
.main {
    background: #ccc;
}

Above snippet is the output when we use postcss-prepend-imports together with postcss-import and postcss-custom-properties.

Installation

npm install postcss-prepend-imports --save-dev

Usage

var options = {
    path: '__tests__/fixtures',
    files: ['colors.css']
};

postcss([ require('postcss-prepend-imports')(options) ])

Options

path

Type: string (default: '')

Set the root folder where postcss-prepend-imports plugin should find files to prepend.

files

Type: array (default: [])

List of file names to prepend in all css files using @import.

See PostCSS docs for examples for your environment.

Keywords

postcss

FAQs

Package last updated on 24 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.