From 85939e9ec64bd1cfbc3fc3c96fce999578a28ca1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 23 Mar 2021 15:22:10 -0500 Subject: [PATCH] Add UnusedFilesWebpackPlugin to detect unused files --- app/fonts/OpenDyslexic/{OFL.txt => LICENSE} | 0 package.json | 1 + webpack/shared.js | 8 ++++++ yarn.lock | 27 +++++++++++++++++++++ 4 files changed, 36 insertions(+) rename app/fonts/OpenDyslexic/{OFL.txt => LICENSE} (100%) diff --git a/app/fonts/OpenDyslexic/OFL.txt b/app/fonts/OpenDyslexic/LICENSE similarity index 100% rename from app/fonts/OpenDyslexic/OFL.txt rename to app/fonts/OpenDyslexic/LICENSE diff --git a/package.json b/package.json index 3701f7718..e2e5510f0 100644 --- a/package.json +++ b/package.json @@ -129,6 +129,7 @@ "ts-jest": "^26.4.1", "typescript": "^4.0.3", "uglifyjs-webpack-plugin": "^2.2.0", + "unused-files-webpack-plugin": "^3.4.0", "uuid": "^8.0.0", "webpack": "^4.41.2", "webpack-assets-manifest": "^3.1.1", diff --git a/webpack/shared.js b/webpack/shared.js index f59e28c2b..c4d0aceb9 100644 --- a/webpack/shared.js +++ b/webpack/shared.js @@ -6,6 +6,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const AssetsManifestPlugin = require('webpack-assets-manifest'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin'); +const { UnusedFilesWebpackPlugin } = require('unused-files-webpack-plugin'); const { env, settings, output } = require('./configuration'); const rules = require('./rules'); @@ -66,6 +67,13 @@ module.exports = { writeToDisk: true, publicPath: true, }), + // https://www.npmjs.com/package/unused-files-webpack-plugin#options + new UnusedFilesWebpackPlugin({ + patterns: ['app/**/*.*'], + globOptions: { + ignore: ['node_modules/**/*', '**/__*__/**/*'], + }, + }), // https://github.com/ampedandwired/html-webpack-plugin new HtmlWebpackPlugin({ template: 'app/index.ejs', diff --git a/yarn.lock b/yarn.lock index d85fb875a..a6d3722e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2778,6 +2778,14 @@ babel-runtime@^6.26.0: core-js "^2.4.0" regenerator-runtime "^0.11.0" +babel-runtime@^7.0.0-beta.3: + version "7.0.0-beta.3" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-7.0.0-beta.3.tgz#7c750de5514452c27612172506b49085a4a630f2" + integrity sha512-jlzZ8RACjt0QGxq+wqsw5bCQE9RcUyWpw987mDY3GYxTpOQT2xoyNoG++oVCHzr/nACLBIprfVBNvv/If1ZYcg== + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + backoff@^2.4.1: version "2.5.0" resolved "https://registry.yarnpkg.com/backoff/-/backoff-2.5.0.tgz#f616eda9d3e4b66b8ca7fca79f695722c5f8e26f" @@ -5570,6 +5578,14 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +glob-all@^3.1.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/glob-all/-/glob-all-3.2.1.tgz#082ca81afd2247cbd3ed2149bb2630f4dc877d95" + integrity sha512-x877rVkzB3ipid577QOp+eQCR6M5ZyiwrtaYgrX/z3EThaSPFtLDwBXFHc3sH1cG0R0vFYI5SRYeWMMSEyXkUw== + dependencies: + glob "^7.1.2" + yargs "^15.3.1" + glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -12211,6 +12227,17 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" +unused-files-webpack-plugin@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/unused-files-webpack-plugin/-/unused-files-webpack-plugin-3.4.0.tgz#adc67a3b5549d028818d3119cbf2b5c88aea8670" + integrity sha512-cmukKOBdIqaM1pqThY0+jp+mYgCVyzrD8uRbKEucQwIGZcLIRn+gSRiQ7uLjcDd3Zba9NUxVGyYa7lWM4UCGeg== + dependencies: + babel-runtime "^7.0.0-beta.3" + glob-all "^3.1.0" + semver "^5.5.0" + util.promisify "^1.0.0" + warning "^3.0.0" + upath@^1.1.1: version "1.1.2" resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.2.tgz#3db658600edaeeccbe6db5e684d67ee8c2acd068"