rollup-plugin-unused
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

rollup-plugin-unused

Rollup plugin to check for unused files.

Usage

This plugin helps you to keep your repository clean: It checks for source files that are not imported during a rollup build and reports them.

Installation

With a modern (lts) version of node.js installed, use npm to install this package:

npm install --save-dev rollup-plugin-unused

Usage

Just add it your rollup.config.js, the default options should be sufficient in most use cases:

import findUnused from 'rollup-plugin-unused';

export default {
  // input and other options

  plugins: [
    // NOTE: It's important that this plugin is added before any plugins that load files!
    findUnused(),

    // other plugins...
  ],
};

By default, the plugin looks for source files with an extension of .js in the ./src/ folder. To change this, you can:

  • Set the extensions option, for example to include TypeScript files:

    findUnused({ extensions: ['.js', '.ts'] });
  • Set the includes option to specify a different source file glob:

    findUnused({ include: ['sources/**/*.mjs'] });

    This will treat all .mjs files inside the ./sources/ folder as source files.

  • Use the exclude option to ignore some files

    findUnused({ exclude: ['src/legacy/*.js'] });

    This will ignore all .js files inside the ./src/ folder.

You can combine exclude with both extensions and include, but include always overrides extensions.

Package Sidebar

Install

npm i rollup-plugin-unused

Weekly Downloads

1,279

Version

0.1.1

License

MIT

Unpacked Size

20.1 kB

Total Files

9

Last publish

Collaborators

  • lhechenberger