shri2021-unused-modules-plugin
v1.0.2
Published
webpack5 plugin to reveal unused modules
Downloads
5
Maintainers
Readme
В репозитории представлен webpack плагин, осуществляющий поиск неиспользуемых модулей в проекте. По умолчанию производится поиск модулей с расширениями .js
и .jsx
в корневой директории, за исключением директории node_modules
. По результатам сравнения списка модулей с метаданными, полученными из webpack
, формируется файл unused.json
. Кастомизация настроек производится в webpack.config.js
. Валидация настроек производится с помощью пакета schema-utils
на основании файла schema.js
.
Плагин можно установить путем клонирования репозитория и импортирования в рабочий проект.
Также доступна установка через npm
(репозиторий приватный, необходим платный npm-аккаунт)
npm i --save-dev shri2021-unused-modules-plugin
yarn add --dev shri2021-unused-modules-plugin
exclude: ['node_modules'],
outputFile: 'unused.json',
baseDir: './',
extensions: ['.js', '.jsx'],
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|exclude
|Array<String>
|['node_modules']
|Список директорий, которые будут проигнорированы при поиске|
|outputFile
|String
|'unused.json'
|Название и путь к файлу с результатами работы плагина|
|baseDir
|String
|'./'
|Корневая директория, относительно которой производится поиск|
|extensions
|Array<String>
|['.js', '.jsx']
|Расширения, используемые при поиске|
webpack.config.js
const { resolve } = require("path");
const unusedModulesPlugin = require("shri2021-unused-modules-plugin");
module.exports = {
mode: "development",
entry: resolve(__dirname, "src/index.js"),
output: {
path: resolve(__dirname, "build"),
filename: "bundle.js"
},
plugins: [new unusedModulesPlugin({
baseDir: './src',
extensions: ['.js', '.jsx', '.ts']
})]
};