Learn how to create and use a shared library across multiple Amplication plugins using npm and Webpack configuration.
dist
folder. This ensures that plugins can run independently without requiring external dependencies at runtime. However, when developing multiple plugins that share common utilities or logic, duplicating code is inefficient. Instead, you can create a shared library that can be locally imported into your plugins using the method described below.
This guide explains how to create a shared library and integrate it into Amplication plugins using npm dependencies and Webpack configuration.
lib
.lib
and create a new package:
package.json
file with the package name shared
.shared
directory, create an index.ts
file and add a utility function:
package.json
of the target plugin, add a local dependency:
@my-org
with your package scope if needed.webpack.config.js
in your plugin directory and add an alias for the shared package: