{"id":13423799,"url":"https://github.com/lucleray/next-purgecss","last_synced_at":"2025-03-31T06:06:28.988Z","repository":{"id":57310608,"uuid":"128206819","full_name":"lucleray/next-purgecss","owner":"lucleray","description":"nextjs + purgecss for smaller css bundles","archived":false,"fork":false,"pushed_at":"2020-03-24T12:34:04.000Z","size":332,"stargazers_count":135,"open_issues_count":8,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T23:09:02.864Z","etag":null,"topics":["next","next-plugins","nextjs","plugins","purgecss"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/next-purgecss","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucleray.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-05T13:00:25.000Z","updated_at":"2024-12-13T15:49:29.000Z","dependencies_parsed_at":"2022-08-26T06:20:31.738Z","dependency_job_id":null,"html_url":"https://github.com/lucleray/next-purgecss","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Fnext-purgecss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Fnext-purgecss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Fnext-purgecss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucleray%2Fnext-purgecss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucleray","download_url":"https://codeload.github.com/lucleray/next-purgecss/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246423731,"owners_count":20774820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["next","next-plugins","nextjs","plugins","purgecss"],"created_at":"2024-07-31T00:00:42.826Z","updated_at":"2025-03-31T06:06:28.964Z","avatar_url":"https://github.com/lucleray.png","language":"JavaScript","funding_links":[],"categories":["Extensions","JavaScript"],"sub_categories":[],"readme":"# next-purgecss\n\nNext.js + Purgecss = 🔥\n\n[Next.js](https://nextjs.org/) makes it easy to create SSR and static React applications.\n\n[Purgecss](https://www.purgecss.com/) helps you remove unused CSS.\n\n## Installation\n\n\u003e 🏎 Check out the [**examples folder**](examples) to see examples for your specific setup.\n\n### 1. Install the packages\n\n`next-purgecss` requires one of the following **css next plugins** :\n\n- [next-css](https://github.com/zeit/next-plugins/tree/master/packages/next-css)\n- [next-less](https://github.com/zeit/next-plugins/tree/master/packages/next-less)\n- [next-sass](https://github.com/zeit/next-plugins/tree/master/packages/next-sass)\n\nJust pick the one that fits your needs. In the following steps, I will use `next-css` but it works the same for the other **css next plugins**.\n\nFor example, install `next-css` and `next-purgecss` :\n\n```\nyarn add @zeit/next-css next-purgecss --dev\n```\n\nor with npm :\n\n```\nnpm install @zeit/next-css next-purgecss --save-dev\n```\n\n### 2. Edit `next.config.js`.\n\n```js\n// next.config.js\nconst withCss = require('@zeit/next-css')\nconst withPurgeCss = require('next-purgecss')\n\nmodule.exports = withCss(withPurgeCss())\n```\n\n## Options\n\n### `purgeCssEnabled`\n\nBy default, `next-purgecss` will always remove unused CSS, regardless of build environment. You can change that by defining a function for the `purgeCssEnabled` option. The `purgeCssEnabled` function receives two arguments:\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `dev` | `Boolean` | `true` in development mode (running `next`) or `false` in production mode (running `next start`) |\n| `isServer` | `Boolean` | `true` during server side compilation or `false` during client side compilation |\n\n```js\n// next.config.js\nmodule.exports = withCss(\n  withPurgeCss({\n    purgeCssEnabled: ({ dev, isServer }) =\u003e (!dev \u0026\u0026 !isServer) // Only enable PurgeCSS for client-side production builds\n  })\n)\n```\n\n### `purgeCssPaths`\n\nBy default, this plugin will scan `components` and `pages`\ndirectories for classnames. You can change that by defining `purgeCssPaths`.\n\n```js\n// next.config.js\nmodule.exports = withCss(\n  withPurgeCss({\n    purgeCssPaths: [\n      'pages/**/*',\n      'components/**/*',\n      'other-components/**/*' // also scan other-components folder\n    ]\n  })\n)\n```\n\n### `purgeCss`\n\nYou can pass custom options to\n[Purgecss](https://github.com/FullHuman/purgecss-webpack-plugin) by defining\n`purgeCss` object in your `next.config.js`.\n\n```js\n// next.config.js\nmodule.exports = withCss(\n  withPurgeCss({\n    purgeCss: {\n      whitelist: () =\u003e ['my-custom-class']\n    }\n  })\n)\n```\n\nThe list of available options are documented in [`purgecss-webpack-plugin`\ndocs](https://github.com/FullHuman/purgecss-webpack-plugin#options).\n\n\u003e ⚠️ `purgeCss.paths` will overwrite `purgeCssPaths`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucleray%2Fnext-purgecss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucleray%2Fnext-purgecss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucleray%2Fnext-purgecss/lists"}