0.0.2 • Published 3 years ago

ds-unused v0.0.2

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

Ds Remove Unused

ds-unused is an easy way to find unused files in your project.

Installation

Make sure you install as a devDependency, otherwise you will add 60mb+ to your build.

$ yarn add ds-unused -D

Usage

In package.json, add a script to find unused files:

"scripts": {
  "find:unused": "ds-unused"
}

Run the script to list any unused files: yarn find:unused.

Configuration

Add a property to your package.json to configure ds-unused:

{
  "ds-unused": {
    "alias": {},
    "include": [],
    "exclude": [],
    "entrypoints": []
  }
}
PropertyTypeDefaultDescription
debugbooleanfalseturn on debug messages
aliasobject{}import aliases in webpack format ({ "@components": "components/" })
includestring[]['pages']list of directories to search through. pages is always included
excludestring[][]array of RegExp that exclude matching filenames
entrypointsstring[]['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:

import Button from '../components/button'

export default () => {
  return (
    <Button>Click me</Button>
  )
}

Configure ds-unused to include the components directory in package.json:

{
  "ds-unused": {
    "include": ["components"]
  }
}

Running ds-unused will output:

Found 1 unused file:
components/image.js