Skip to content

CodeCoupler Webpack Externals Plugin Dynamically load assets

If you want to load stylesheets, scripts or other assets dynamically in your code you have to know the path to the copied files. Because the path include amongst other things the version number this can not be determined easily. Therefore the plugin will inject a global variable ccExternals where you can read the needed path. The variable holds an array where the key is the module name. If you use an alias, the alias name will be used. For each key the corresponding value is the relative path from the root of your application to the root of the module.

Example:

1
window.ccExternals["module-name"] === "vendor/module-name-1.2.3";