unused-webpack-plugin
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -22,4 +22,5 @@ const path = require('path'); | ||
root: __dirname, | ||
failOnUnused: true | ||
}), | ||
], | ||
}; |
14
index.js
@@ -9,2 +9,3 @@ const path = require('path'); | ||
this.root = options.root; | ||
this.failOnUnused = options.failOnUnused || false; | ||
} | ||
@@ -36,2 +37,3 @@ | ||
.then(display.bind(this)) | ||
.then(continueOrFail.bind(this, this.failOnUnused, compilation)) | ||
.then(callback); | ||
@@ -44,2 +46,12 @@ }.bind(this) | ||
function continueOrFail(failOnUnused, compilation, allFiles) { | ||
if (allFiles && allFiles.length > 0) { | ||
if (failOnUnused) { | ||
compilation.errors.push(new Error("Unused files found")); | ||
} else { | ||
compilation.warnings.push(new Error("Unused files found")); | ||
} | ||
} | ||
} | ||
function display(filesByDirectory) { | ||
@@ -71,2 +83,4 @@ const allFiles = filesByDirectory.reduce( | ||
process.stdout.write(chalk.green('\n*** Unused Plugin ***\n\n')); | ||
return allFiles; | ||
} |
{ | ||
"name": "unused-webpack-plugin", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A webpack plugin to find unused modules/source files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -40,6 +40,10 @@ # UnusedWebpackPlugin | ||
- `root` : root directory that will be use to display relative paths instead of absolute ones (see below) | ||
- `failOnUnused`: whether or not the build should fail if unused files are found (defaults to `false`) | ||
With root | ||
 | ||
Without root | ||
 |
Sorry, the diff of this file is not supported yet
102
49
232074
22