A Webpack plugin to dynamically add a resource to the dependency graph during compilation.
This is useful when working with dynamically generated files that should be tracked by Webpack.
✔ Dynamically adds a resource to Webpack's dependency graph
✔ Prevents missing file errors by checking existence before adding
✔ Supports Webpack 4 and 5
✔ Professional error handling
✔ Lightweight & zero external dependencies
Install via NPM:
npm install webpack-dynamic-resource --save-dev
Or via Yarn:
yarn add webpack-dynamic-resource --dev
Modify your webpack.config.js
:
const DynamicResourcePlugin = require("webpack-dynamic-resource");
module.exports = {
plugins: [
new DynamicResourcePlugin({
resourcePath: "./src/generated-file.js", // The file Webpack should track
}),
],
};
This ensures that Webpack recompiles whenever ./src/generated-file.js
changes.
Option | Type | Default | Description |
---|---|---|---|
resourcePath |
string |
null |
Path to the file Webpack should track dynamically. |
This project is licensed under the MIT License - see the LICENSE file for details.
Created by The Another Studios
For inquiries, visit theanotherstudios.com or contact us via GitHub.
Contributions are welcome!
Please open an issue or submit a pull request.