B
B
be_a_man2020-06-16 18:36:06
JavaScript
be_a_man, 2020-06-16 18:36:06

How to use dynamic import of external script?

How to use webpack dynamic import if the script is connected from an external domain.

An external app.js script from the appcdn.com domain connects to
site.com. Dynamic import is used in app.js.

How do I tell webpack when building app.js that chunks should be loaded from appcdn.com?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2020-06-16
@be_a_man

publicPath
Personally, I like the feature __webpack_public_path__: with the installation of dynamically from document.currentScript, you can not bathe at all where everything will lie.
But if the addresses will not change, then the static one publicPathis of course more reliable.
PS Just in case: if several webpack bundles are used on one page, you should not forget to set a unique jsonpFunction for each, otherwise there may be collisions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question