0.2.1 • Published 5 years ago

webpack-incremental-ident v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Webpack Incremental Ident

Webpack plugin transform your css class name into shortest form.

npm node deps licenses

css

✍️ Using incremental class names causes problem because of two reasons:

  • Webpack potentially compiles input files in different order.
  • You change the order when using require/import.

This plugin solves the problem above by keeping track of incremental class names and reuse them for following compilings.

Installation

Via npm:

$ npm install webpack-incremental-ident --save-dev

Via yarn:

$ yarn add -D webpack-incremental-ident

Usage

const IncrementalCSS  = require('webpack-incremental-ident');

const webpackConfig = {
  ...
  module: {
    rules: [
      {
        test: /\.css$/,
        loader: 'css-loader',
        options: {
          getLocalIdent: IncrementalCSS.getLocalIdent,
        }
      }
    ]
  },
  plugins: [
    new IncrementalCSS({
      logPath: path.resolve(__dirname, '../stats/css.json'),
      blacklist: [/^ad$/]
    })
  ]
}

Configuration

new IncrementalCSS(options);

options.logPath

  • Type: String
  • Required

Path to your json file to keep track of your incremental class names.

options.characters

  • Type: Array
  • Default: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_

Characters are included in class names.

options.fallbackIdent

  • Type: String
  • Default: ""

Fallback to an ident name strategy if classname doesn't exist in logPath

options.blacklist

  • Type: Array of regex
  • Default: []

List of class names will be ignored for example ad

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago