🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

postcss-filename-prefix

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-filename-prefix

Postcss plugin for prefixing classes with corresponding filenames

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
2
Created
Source

postcss-filename-prefix

A PostCSS plugin to prefix classes with corresponding filenames
The idea is to isolate styles in framework components

js-standard-style

MyComponent.css

.myclass { /* ... */ }
.-mymodifier { /* ... */ }
.Mycapitalclass { /* ... */ }

Output:

.MyComponent-myclass { /* ... */ }
.-mymodifier { /* ... */ }
.Mycapitalclass { /* ... */ }

Ignores:

  • filenames that starts from not capital letter
  • modifiers (classes that starts from hyphen)
  • classes that starts from capital letter

Installation

npm install postcss-filename-prefix

Usage

var fs        = require('fs');
var postcss   = require('postcss');
var filenamePrefix = require('postcss-filename-prefix');

var css = fs.readFileSync('css/MyFile.css', 'utf8').toString();
var out = postcss()
          .use(filenamePrefix())
          .process(css);

Using the ignore option

var fs        = require('fs');
var postcss   = require('postcss');
var filenamePrefix = require('postcss-filename-prefix');

var css = fs.readFileSync('css/MyFile.css', 'utf8').toString();
var out = postcss()
          .use(filenamePrefix({ ignore: [/ng-/, 'some-class-to-ignore']}))
          .process(css);

License

MIT

Recommendation

Acknowledgements

Keywords

css

FAQs

Package last updated on 02 Jul 2020

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