1.1.1 • Published 2 years ago

@xhoantran/next-purgecss v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Next PurgeCss

Next PurgeCss is a plugin that makes removing unused css in Next.js projects.

Table of contents

Getting Started

NextPurgeCss works by adding its CLI in package.json file. Once you build your Next.js application, Next-PurgeCss will look into your build folder, get all the used selector, then purge the unused.

Installation

To install the library, run:

$ npm install @xhoantran/next-purgecss

Or if you prefer using Yarn:

$ yarn add @xhoantran/next-purgecss

Usage

Add next-purgecss as your postbuild script

"scripts": {
  "build": "next build",
  "postbuild": "next-purgecss"
}

Configuration

You can add the configuration directly in the Next.js config file (next.config.js).

module.exports = {
  rejected: true,
  rejectedCss: true,
  safelist: [
    "container-fluid",
    "navbar-collapse",
    "navbar-expand-lg",
    "navbar-nav",
  ],
};

Configuration Options

PropertyTypeDescription
fontFaceboolean (default false)Set whether unused @font-face rules will be remove or not
keyframesboolean (default false)Set whether unused keyframes rules will be remove or not
variablesboolean (default false)Set whether unused variables will be remove or not
rejectedboolean (default false)Set true to scan through the removed list to see if there's anything obviously wrong
safeliststring[] or objectIndicate which selectors are safe to leave in the final CSS More Info
blocklistarray of regrex and stringBlocklist will block the CSS selectors from appearing in the final output CSS

Built With

License

MIT License © Hoan Tran

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago