{"id":17696786,"url":"https://github.com/eels/next-purge-css-modules","last_synced_at":"2025-05-07T14:26:27.603Z","repository":{"id":37981581,"uuid":"448318841","full_name":"eels/next-purge-css-modules","owner":"eels","description":"Easily remove unused css-module code in your Next.js application","archived":false,"fork":false,"pushed_at":"2023-12-23T17:24:08.000Z","size":58,"stargazers_count":15,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T14:36:56.783Z","etag":null,"topics":["css","css-modules","nextjs","nextjs-plugin","purgecss","scss"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/next-purge-css-modules","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eels.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-15T15:42:00.000Z","updated_at":"2025-02-26T12:49:22.000Z","dependencies_parsed_at":"2023-12-23T18:30:43.048Z","dependency_job_id":"31305c9b-564c-47a3-843d-743c6c150774","html_url":"https://github.com/eels/next-purge-css-modules","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":0.2727272727272727,"last_synced_commit":"db6476e2f60d88ed276cc7e9f37ecf7db53d41ab"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eels%2Fnext-purge-css-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eels%2Fnext-purge-css-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eels%2Fnext-purge-css-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eels%2Fnext-purge-css-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eels","download_url":"https://codeload.github.com/eels/next-purge-css-modules/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252894008,"owners_count":21820908,"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":["css","css-modules","nextjs","nextjs-plugin","purgecss","scss"],"created_at":"2024-10-24T14:45:20.750Z","updated_at":"2025-05-07T14:26:27.586Z","avatar_url":"https://github.com/eels.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\n    \u003cbr /\u003e\n    \u003cdiv\u003e:construction_worker:\u003c/div\u003e\n    \u003cbr /\u003e\n    \u003cdiv\u003enext-purge-css-modules\u003c/div\u003e\n    \u003cbr /\u003e\n  \u003c/h1\u003e\n  \u003cbr /\u003e\n  \u003cdiv\u003eEasily remove unused css-module code in your \u003ca href=\"https://github.com/vercel/next.js\"\u003eNext.js\u003c/a\u003e application\u003c/div\u003e\n  \u003cbr /\u003e\n  \u003ca href=\"https://www.npmjs.com/package/next-purge-css-modules\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/next-purge-css-modules?style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://coveralls.io/github/eels/next-purge-css-modules\"\u003e\u003cimg src=\"https://img.shields.io/coveralls/github/eels/next-purge-css-modules?label=Coverage\u0026style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/eels/next-purge-css-modules/actions/workflows/codeql-analysis.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/eels/next-purge-css-modules/codeql-analysis.yml?branch=main\u0026label=CodeQL\u0026style=flat-square\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/next-purge-css-modules\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/next-purge-css-modules?label=Downloads\u0026style=flat-square\" /\u003e\u003c/a\u003e\n  \u003cbr /\u003e\u003cbr /\u003e\n  \u003cpre\u003eyarn add \u003ca href=\"https://www.npmjs.com/package/next-purge-css-modules\"\u003enext-purge-css-modules\u003c/a\u003e --dev\u003c/pre\u003e\n  \u003ch1\u003e\u003c/h1\u003e\n\u003c/div\u003e\n\n## Contents\n\n- [Installation](#installation)\n- [Example Usage](#example-usage)\n- [Configuration](#configuration)\n- [Usage With Sass](#usage-with-sass)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\n`next-purge-css-modules` can be installed using your favourite JavaScript package manager.\n\n```bash\nyarn add next-purge-css-modules --dev\n```\n\n```bash\nnpm install next-purge-css-modules --save-dev\n```\n\n## Example Usage\n\nIf your Next.js project does not already contain one, create a `next.config.js` file in the root of your project directory.\n\n```js\nconst withPurgeCSSModules = require('next-purge-css-modules');\n\n/** @type {import('next-purge-css-modules').PurgeConfig} */\nconst purgeConfig = { ... };\n\nmodule.exports = withPurgeCSSModules(purgeConfig);\n```\n\nYou can read more about the advanced configuration of Next.js on the [official documentation site](https://nextjs.org/docs/api-reference/next.config.js/introduction).\n\n## Configuration\n\nThis plugin comes preconfigured with some sensible defaults options. However, you are free to alter this configuration to suit your project needs with the use of the custom purge config object via the `next.config.js` file.\n\nAdditionally, you can also pass your custom next config object as the function's second argument.\n\n```ts\ninterface PurgeCSSModulesOptions {\n  content?: string | string[];\n  enableDevPurge?: boolean;\n  fontFace?: boolean;\n  keyframes?: boolean;\n  safelist?: UserDefinedSafelist;\n  variables?: boolean;\n}\n```\n\n```js\nconst path = require('path');\nconst withPurgeCSSModules = require('next-purge-css-modules');\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  ...\n};\n\n/** @type {import('next-purge-css-modules').PurgeConfig} */\nconst purgeConfig = {\n  content: path.join(__dirname, 'src/**/*.{js,jsx,ts,tsx}'),\n  enableDevPurge: true,\n  safelist: ['body', 'html'],\n};\n\nmodule.exports = withPurgeCSSModules(purgeConfig, nextConfig);\n```\n\n### `content`\n\nThis option tells `next-purge-css-modules` which files to look through to check for unused css-modules. You can either supply these files as absolute paths or as file path globs and they can either be a single path or an array.\n\nThe default value looks at all JavaScript/TypeScript files in the default Next.js pages directories (`app/**/*.{js,jsx,ts,tsx}`, `pages/**/*.{js,jsx,ts,tsx}`, `src/app/**/*.{js,jsx,ts,tsx}` and `src/pages/**/*.{js,jsx,ts,tsx}`).\n\n### `enableDevPurge`\n\nBy default, your css-module code will only be purged when a `production` build is generated. You can set this flag to `true` to enable css-modules purging when running your Next.js project in `development` mode.\n\n### `fontFace`\n\nIf there are any unused @font-face rules, setting this flag to `true` will purge them from the final output. By default is `false`.\n\n### `keyframes`\n\nAny unused animation keyframes found within your css-module code will be purged from the final output when this flag is set to `true`. By default is `false`.\n\n### `safelist`\n\nBy supplying an array of CSS selectors to the `safelist` option, you can tell `next-purge-css-modules` which selectors you wish to ensure are not purged. By default is `['body', 'html']`\n\nTo read more about the `safelist` configuration option, you can refer to the official [PurgeCSS documentation](https://purgecss.com/configuration.html).\n\n### `variables`\n\nWhen you are using Custom Properties (CSS variables), or a library using them such as Bootstrap, setting this flag to `true` will purge them from the final output.\n\n## Usage With Sass\n\n`next-purge-css-modules` works directly out of the box with Next.js projects set up to use Sass.\n\nYou can refer to the [official Next.js Sass documentation](https://nextjs.org/docs/basic-features/built-in-css-support#sass-support) to ensure your project is set up correctly.\n\n## Contributing\n\nThanks for taking the time to contribute! Before you get started, please take a moment to read through our [contributing guide](https://github.com/eels/next-purge-css-modules/blob/main/.github/CONTRIBUTING.md). The focus area for `next-purge-css-modules` right now is fixing potential bugs.\n\nHowever, all issues and PRs are welcome!\n\n## License\n\nMIT - see the [LICENSE.md](https://github.com/eels/next-purge-css-modules/blob/main/LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feels%2Fnext-purge-css-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feels%2Fnext-purge-css-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feels%2Fnext-purge-css-modules/lists"}