getPublicPath
-
Type:
string -
Required: No
-
Default value:
undefined -
Effective condition: only effective when
exposesis set -
Purpose: Used to set a dynamic
publicPath. The value must be a stringified function or a stringified return expression. When other consumers load this provider, the string ingetPublicPathwill be executed vianew Functionto obtain the return value, which will be used as thepublicPathprefix for the module’s static assets.- Function form:
function(){ return window.cdn_prefix } - Return form:
return "https:" + window.navigator.cdn_host + "/resource/app/"
- Function form:
-
Example:
In the example below, getPublicPath is set. When other consumers load this provider, the string in getPublicPath will be executed using new Function to obtain the value, which will be used as the publicPath prefix for the module’s static assets.
getPublicPath must be a stringified function or a stringified return expression.
If you're using the module federation webpack plugin and want to set a dynamic publicPath, you should set __webpack_public_path__ = window.cdn_prefix in the getPublicPath function body.