Skip to content

Commit

Permalink
🎉 First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Lemoine committed Oct 7, 2017
0 parents commit 37348a9
Show file tree
Hide file tree
Showing 24 changed files with 4,952 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"node": true,
"es6": true,
},
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# UnusedWebpackPlugin

A webpack plugin to find unused modules/source files.

![unused-webpack-plugin](images/with-root.png)

## Install

```
npm i --dev unused-webpack-plugin
```

## Usage

```javascript
const path = require('path');
const UnusedWebpackPlugin = require('unused-webpack-plugin');

module.exports = {
// webpack configuration
plugins : [
...otherPlugins,
new UnusedWebpackPlugin({
// Source directories
directories : [path.join(__dirname, 'src')],
// Exclude patterns
exclude : ['*.test.js',],
// Root directory (optional)
root : __dirname,
}),
],
}
```

## Options

- `directories` : array of directories where to look for unused source files.
- `exclude` : array of exclude patterns when looking for unused source files.
- `root` : root directory that will be use to display relative paths instead of absolute ones (see below)

With root
![With root](images/with-root.png)
Without root
![Without root](images/without-root.png)
1 change: 1 addition & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require('./simple-module/utils')
require('./awesome-module/actions/teleport');
15 changes: 15 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "example",
"version": "1.0.0",
"description": "A webpack plugin to find unused modules i.e source files",
"main": "index.js",
"repository": "https://github.com/MatthieuLemoine/unused-webpack-plugin",
"author": "MatthieuLemoine",
"license": "MIT",
"scripts": {
"build": "webpack"
},
"devDependencies": {
"webpack": "^3.6.0"
}
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');
const UnusedWebpackPlugin = require('../');

module.exports = {
target : 'node',
entry : path.resolve(__dirname, 'index.js'),
output : {
path : path.join(__dirname, 'dist'),
filename : 'bundle.js',
},
plugins : [
new UnusedWebpackPlugin({
// Source directories
directories : [path.join(__dirname, 'awesome-module'), path.join(__dirname, 'simple-module')],
// Exclude patterns
exclude : ['*.test.js',],
// Root directory (optional)
root : __dirname,
}),
]
}
Loading

0 comments on commit 37348a9

Please sign in to comment.