undefined
At build time, prevent some import
dependencies from being packed into bundles in your code, and instead fetch them externally at runtime.
For more information, please see: Rspack Externals.
Exclude the react-dom
dependency from the output bundle. To get this module at runtime, the value of react-dom
will globally retrieve the ReactDOM
variable.
Use an array to define multiple external configurations:
A common use case is to load libraries from CDN and exclude them from your bundle, then use html.tags to include them in your HTML.
Then you can use the external libraries in your source code:
Use regular expressions to match multiple modules with a pattern:
If output.target is web-worker
, externals will not take effect. This is because the Web Worker environment cannot access global variables.