Remove unused CSS

栏目: IT技术 · 发布时间: 6年前

内容简介:When you are building a website, chances are that you are using a css framework like Bootstrap, Materializecss, Foundation, etc... But you will only use a small set of the framework and a lot of unused css styles will be included.

PurgeCSS

Remove unused CSS

What is PurgeCSS?

When you are building a website, chances are that you are using a css framework like Bootstrap, Materializecss, Foundation, etc... But you will only use a small set of the framework and a lot of unused css styles will be included.

This is where PurgeCSS comes into play. PurgeCSS analyzes your content and your css files. Then it matches the selectors used in your files with the one in your content files. It removes unused selectors from your css, resulting in smaller css files.

Version 1

If you are looking for PurgeCSS 1 , the documentation is here

Documentation

You can find the PurgeCSS documentation on this website .

Table of Contents

PurgeCSS

Plugins

Guides

Getting Started

Installation

npm i --save-dev purgecss

Usage

import PurgeCSS from 'purgecss'
const purgeCSSResults = await new Purgecss().purge({
  content: ['**/*.html'],
  css: ['**/*.css']
})

Packages

This repository is a monorepo that we manage using Lerna . That means that we actually publish several packages to npm from the same codebase, including:

Package Version Description
purgecss The core of PurgeCSS
postcss-purgecss PostCSS plugin for PurgeCSS
purgecss-webpack-plugin Webpack plugin for PurgeCSS
gulp-purgecss Gulp plugin for PurgeCSS
grunt-purgecss Grunt plugin for PurgeCSS
purgecss-from-html Html extractor for PurgeCSS
purgecss-from-js Js extractor for PurgeCSS
purgecss-from-pug Pug extractor for PurgeCSS
purgecss-with-wordpress Collection of whitelist items for WordPress

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

若为自由故

若为自由故

[美] Sam Williams / 邓楠、李凡希 / 人民邮电出版社 / 2015-4 / 49

理查德·马修·斯托曼(Richard Matthew Stallman,简称RMS)是自由软件之父,他是自由软件运动的精神领袖、GNU计划以及自由软件基金会的创立者。作为一个著名的黑客,他的主要成就包括Emacs及后来的GNU Emacs、GNU C 编译器及GDB 调试器。他编写的GNU通用公共许可证(GNU GPL)是世上最广为采用的自由软件许可证,为copyleft观念开拓出一条崭新的道路。......一起来看看 《若为自由故》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换