ITADN

Optimize LicenseWebpackPlugin Behavior in Development Mode

#132Openjdieckmannelm 创建于 2024-11-04
J
jdieckmannelmcommented
We are using `webpack` and `LicenseWebpackPlugin` to manage licensing information for a large number of modules in our project. Due to the volume of dependencies, generating the licenses takes approximately 5 seconds, and it currently re-runs on every file change within the `src/` folder when using the `webpack-dev-server`. This repeated generation feels excessive and significantly slows down development. The generated `licenses.json` file contains approximately 1800 licenses, and it seems that there is no caching taking place for the license generation process, even though the `webpack` `cache` has been activated. While it would be ideal to skip license generation during development, we can't disable it entirely because we need to generate a `licenses.json` file that is an official part of our application. We're looking for an optimization or workaround that would prevent redundant re-runs of `LicenseWebpackPlugin` during development without fully disabling it. Environment: - `webpack@5.93.0` - `webpack-cli@5.1.4` - `webpack-dev-server@5.0.4` - `license-webpack-plugin@4.0.2` The configuration for the `LicenseWebpackPlugin` is as follows: ```javascript const licenseWebpackPluginConfig = { outputFilename: 'licenses.json', addBanner: true, renderBanner: (filename) => { return `/*! licenses are at ${filename} */`; }, renderLicenses: (modules) => { return JSON.stringify( modules.map((mod) => { return { name: mod.name, version: mod.packageJson.version, // ... }; }) ); }, perChunkOutput: false, modulesDirectories: [path.resolve(__dirname, 'node_modules')], // ... }; ``` However, the behavior also seems to exist with a more or less out-of-the-box default configuration. We would appreciate any support or guidance on this matter and are happy to offer assistance if needed.
0 条评论