Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pacocoursey/next-unused
Find unused files in your Next.js projects
https://github.com/pacocoursey/next-unused
Last synced: 1 day ago
JSON representation
Find unused files in your Next.js projects
- Host: GitHub
- URL: https://github.com/pacocoursey/next-unused
- Owner: pacocoursey
- Archived: true
- Created: 2020-04-17T06:00:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-07T18:43:05.000Z (3 months ago)
- Last Synced: 2024-10-08T02:51:12.495Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 233 KB
- Stars: 421
- Watchers: 6
- Forks: 15
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- Awesome-NextJs - next-unused - `Find unused files in your Next.js projects` (Nextjs Plugins)
README
# next-unused
next-unused is an easy way to find unused files in your [Next.js](https://github.com/zeit/next.js) project.
## Installation
Install as a `devDependency`:
```
$ yarn add next-unused -D
```### Usage
In `package.json`, add a script to find unused files:
```json
"scripts": {
"find:unused": "next-unused"
}
```Run the script to list any unused files:
```
$ yarn find:unused
```### Configuration
Add a property to your `package.json` to configure next-unused:
```json
{
"next-unused": {
"alias": {},
"include": [],
"exclude": [],
"entrypoints": []
}
}
```| Property | Type | Default | Description |
| ------------- | -------- | --------- | ---------------------------------------------------------------------- |
| `debug` | boolean | `false` | turn on debug messages |
| `alias` | object | `{}` | import aliases in webpack format (`{ "@components": "components/" }`) |
| `include` | string[] | `['pages']` | list of directories to search through. `pages` is always included |
| `exclude` | string[] | `[]` | array of RegExp that exclude matching filenames |
| `entrypoints` | string[] | `['pages']` | list of directories to use as entrypoints. `pages` is always included |### Example
Your Next.js setup looks like this:
```
package.json
├─ pages/
│ ├─ index.js
└─ components/
├─ button.js
└─ image.js
```And your `pages/index.js` contains:
```js
import Button from '../components/button'export default () => {
return (
Click me
)
}
```Configure `next-unused` to include the `components` directory in `package.json`:
```json
{
"next-unused": {
"include": ["components"]
}
}
```Running `next-unused` will output:
```
Found 1 unused file:
components/image.js
```### Credits
Shu and Luc wrote the initial version of this script.
- [Shu](https://twitter.com/shuding_)
- [Luc](https://twitter.com/lucleray)