@gravityforms/dependency-extraction-webpack-plugin
v5.3.2
Published
Dependency extraction webpack plugin for use in Gravity Forms development. Extends the WordPress plugin.
Downloads
1,192
Readme
Gravity Forms Dependency Extraction Webpack Plugin
This plugin enhances the WordPress Dependency Extraction Webpack Plugin by adding automatic inclusion of Gravity Forms dependencies alongside WordPress dependencies. Use this if you are developing features or add-ons that extend Gravity Forms and want to use our externals instead of bundling our code yourselves. This is also used by the Gravity Forms plugin itself.
Installation
To install the module, use the following command:
npm install @gravityforms/dependency-extraction-webpack-plugin --save-dev
Usage
Integrate this plugin just like you would with the Dependency Extraction Webpack Plugin. The API remains identical, except for a few custom options we have added listed below, but it now also processes Gravity Forms packages automatically.
const GravityFormsDependencyExtractionWebpackPlugin = require('@gravityforms/dependency-extraction-webpack-plugin');
module.exports = {
// other webpack config
plugins: [new GravityFormsDependencyExtractionWebpackPlugin()],
};
Options
You can pass an object to the constructor to modify the plugin's behavior, for instance:
module.exports = {
plugins: [
new GravityFormsDependencyExtractionWebpackPlugin({
bundledPackages: ['@gravityforms/libraries'],
}),
],
};
bundledPackages
- Type: array
- Default: []
This option specifies an array of packages to ignore during externals mapping. These packages will be included within your bundle and not mapped to the external.
An important note on our @gravityforms/components
package. If you pass @gravityforms/components
here, it will exclude all the components, but you can also pass @gravityforms/components/react/admin/modules/Dialog
to only exclude the Dialog component. This could be useful if you want to use a version of the package that has that component in a state that is ahead of what core has shipped with. All other components will map to our externals, but this one will be included in the bundle.
rootNamespace
- Type: string
- Default: 'gform'
If you are using our components by enqueuing the compiled files yourself instead of using the ones enqueued by Gravity Forms, you need to set this option to the same one you used in that package. Check the components readme for more details.
For more configuration options, refer to the original dependency extraction plugin.