Link to an UMD node_module in app.blade.php #51236
Unanswered
mrleblanc101
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've added
<script src="{{ Vite::asset("node_modules/vanilla-cookieconsent/dist/cookieconsent.umd.js") }}"></script>
in my head, but I get this error at build-time:Unable to locate file in Vite manifest: node_modules/vanilla-cookieconsent/dist/cookieconsent.umd.js.
If I look at the manifest, I see I could add
?commonjs-entry
to make the link work, but I cannot find any information about this. Also this seems to wrap the UMD code so that CookieConsent is not added to the global scope, which is not what I want.I could import the ESM version like so
import * as CookieConsent from 'vanilla-cookieconsent';
and link it like so@vite(['resources/js/cookie-consent.js']
, but this would create a<script type="module">
which would be executed after my GTM Script initialization which is a regular<script>
.Script type="module" are executed after
DOMContentLoaded
, while regular<script>
are blocking and executed immediatly.Beta Was this translation helpful? Give feedback.
All reactions