rollup-plugin-unused
v0.1.1
Published
Rollup plugin to check for unused files
Downloads
4,455
Maintainers
Readme
rollup-plugin-unused
Rollup plugin to check for unused files.
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.