Socket
Socket
Sign inDemoInstall

postcss-parent-selector

Package Overview
Dependencies
11
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-parent-selector

PostCSS plugin for adding a parent selector to all rules in a css file.


Version published
Weekly downloads
9.2K
decreased by-8.42%
Maintainers
1
Install size
1.42 MB
Created
Weekly downloads
 

Changelog

Source

[1.0.0] - 2016-12-03

Changes

  • initial release
  • add string of text to the beginning of all selectors, ignoring at-rules like @keyframes

Readme

Source

postcss-parent-selector Build Status

PostCSS plugin for adding a parent selector to all rules in a CSS file.

Example

Options:

{selector: '.parent'}

Input CSS:

.foo {
    /* Input example */
}


.foo .bar,
div.foo .bar {
    /* Input example */
}

Output CSS:

.parent .foo {
    /* Input example */
}


.parent .foo .bar,
.parent div.foo .bar {
    /* Input example */
}

Options

The selector option takes a string value that should be placed at the beginning of each selector, including selector lists separated by commas.

// class
{selector: '.parent-class'}

// id
{selector: '#parent-id'}

// element
{selector: 'div.parent-class'}

Usage

postcss([ require('postcss-parent-selector') ])

See PostCSS docs for examples for your environment.

Gulp.js ( with babel )

import gulp from 'gulp';
import plumber from 'gulp-plumber';
import sass from 'gulp-sass';
import postcss from 'gulp-postcss';
import parentSelector from 'postcss-parent-selector';

gulp.task('styles', () => {

     // array containing postcss plugins
    var processors = [
        parentSelector({selector: '.parent'})
    ];

    // source compiled css or scss files
    return gulp.src('./path/to/*.scss')
        .pipe(plumber())
        // scss compiling
        .pipe(sass.sync({
            outputStyle: 'expanded',
            precision: 10,
            includePaths: ['.']
        }).on('error', sass.logError))
        // postcss processes the compiled css
        .pipe(postcss(processors))
        .pipe(gulp.dest('./path/to/dest'))
        .pipe(reload({ stream: true }));
});

Keywords

FAQs

Last updated on 02 Dec 2016

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc