Skip to content

JPeer264/node-rename-css-selectors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rename CSS Selectors

Build Status

This library renames all CSS selectors in the given files. It will collect all selectors from the given CSS files, it does not matter if those are scss or even plain css files.

You can also use a config file, if you already had other projects with the same classes. So all your projects have the same minified selector names - always.

Installation

Install with npm or yarn

npm install --save rename-css-selectors

or

yarn add rename-css-selectors

Usage

const rcs = require('rename-css-selectors')


// first you have to process the css files
// to get a list of variables you want to minify
// options is optional
rcs.processCss('**/*.css', options, err => {
    // all css files are now saved and renamed

    // now it is time to process all other files
    rcs.process('**/*.js', options, err => {
        // that's it
    });
});

Methods

processCss

processCss(src, [options], callback)

Store all matched selectors into the library and saves the new generated file with all renamed selectors.

Options:

  • overwrite (boolean): ensures that it does not overwrite the same file accidently. Default is false
  • cwd (string): the working directory in which to seach. Default is process.cwd()
  • newPath (string): in which folder the new files should go. Default is rcs
  • flatten (boolean): flatten the hierarchie - no subfolders. Default is false

Example:

const rcs = require('rename-css-selectors')

rcs.processCss('**/*.css', options, err => {
    if (err) return console.error(err)

    console.log('Successfully wrote new files and stored values');
}

process

process(src, [options], callback)

generateLibraryFile

generateLibraryFile(pathLocation, [options], callback)

About

📝 Rename css classes and id's in files

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •