Created
April 14, 2026 11:59
-
-
Save fago/712ebf94be0bcb987de4535672b97e3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/js/nuxt-app-loader.js b/js/nuxt-app-loader.js | |
| new file mode 100644 | |
| index 0000000..eabbd9b | |
| --- /dev/null | |
| +++ b/js/nuxt-app-loader.js | |
| @@ -0,0 +1,28 @@ | |
| +/** | |
| + * @file | |
| + * Loads the Nuxt app-loader script for component preview. | |
| + * | |
| + * Runs immediately in <head> (no Drupal behavior) so the Nuxt app starts | |
| + * bootstrapping during HTML parsing, before footer JS loads. | |
| + * | |
| + * Sets window.__nuxtComponentPreviewFailed on error so the nuxt-preview | |
| + * behavior can show per-component error messages. | |
| + */ | |
| + | |
| +((drupalSettings) => { | |
| + const baseUrl = drupalSettings?.customElementsNuxtPreview?.baseUrl; | |
| + if (!baseUrl) { | |
| + return; | |
| + } | |
| + | |
| + const script = document.createElement('script'); | |
| + script.src = `${baseUrl}/nuxt-component-preview/app-loader.js`; | |
| + script.setAttribute('data-cdn-url', baseUrl); | |
| + script.setAttribute('data-build-assets-dir', '/_nuxt/'); | |
| + | |
| + script.onerror = () => { | |
| + window.__nuxtComponentPreviewFailed = true; | |
| + }; | |
| + | |
| + document.head.appendChild(script); | |
| +})(drupalSettings); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment