Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jl-/postifycss-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpack loader for css purify and deduplication, remove unused and duplicated css rules


npm install postifycss-loader --save-dev
var PostifyCssPlugin = require('postifycss-loader/plugin');

function makeStyleLoader(isDev, isLocal) {
  let baseLoader = `css?importLoaders=${isDev ? 2 : 3}${isLocal ? '&modules&localIdentName=[name]_[local]_[hash:base64:5]' : ''}!autoprefixer${isDev ? '' : '!postifycss'}!sass`;
  let conf =  {
    test: /\.(css|scss)$/,
    loader: isDev ? `style!${baseLoader}` : ExtractTextPlugin.extract('style', baseLoader, extractTextConf)
  };
  conf[isLocal ? 'exclude' : 'include'] = /statics\/libs/;
  return conf;
}

...

{
  module: {
    loaders: [
      makeStyleLoader(false, false),
    ]
  },
  plugins: [new PostifyCssPlugin({})]
}

new PostifyCssPlugin(options)

  • staticContent // String|Array [optional], absolute path of html or js files, contents will be concated and passed along to purifycss(contents,..);

  • override // boolean [optional], whether to override the output bundle css file, default false.

      `true` => emit the purified and deduplicated css file
    
      `false` => emit (the purified file) and (the purified & deduplicated file with suffixed filename)
    
  • suffix // string [optional], if override!==true, use this as the emited postified css filename suffix, default .pf;

case: 192kb -> 33kb

About

webpack loader for css purify and deduplication: purifycss(uncss) | deduplicate css

Resources

License

Stars

Watchers

Forks

Packages

No packages published