Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Astro/Vite fails to properly mount Vue #18

Closed
kcole93 opened this issue Sep 4, 2022 · 5 comments
Closed

Astro/Vite fails to properly mount Vue #18

kcole93 opened this issue Sep 4, 2022 · 5 comments

Comments

@kcole93
Copy link

kcole93 commented Sep 4, 2022

After installing astro-netlify-cms and adding a basic config entry in astro.config.mjs, Vue components failed to render as the Vue instance was seemingly not being properly mounted.

Fails to render Vue components

export default defineConfig({
  site: 'https://example.com',
  integrations: [
    mdx(),
    sitemap(),
    vue(),  // Vue integration declared before NetlifyCMS
    NetlifyCMS({
      config: {
        backend: {
          name: 'git-gateway',
          branch: 'master'
        },
        collections: [
          {
            name: 'posts',
            label: 'Blog Posts',
            folder: 'src/pages/blog',
            create: true,
            delete: true,
            fields: [
              { name: 'title', widget: 'string', label: 'Post Title' },
              { name: 'body', widget: 'markdown', label: 'Post Body' },
            ],
          },
        ]
      }
     }),
  ],
});

Properly renders Vue components

export default defineConfig({
  site: 'https://example.com',
  integrations: [
    mdx(),
    sitemap(),
    NetlifyCMS({
      config: {
        backend: {
          name: 'git-gateway',
          branch: 'master'
        },
        collections: [
          {
            name: 'posts',
            label: 'Blog Posts',
            folder: 'src/pages/blog',
            create: true,
            delete: true,
            fields: [
              { name: 'title', widget: 'string', label: 'Post Title' },
              { name: 'body', widget: 'markdown', label: 'Post Body' },
            ],
          },
        ]
      }
     }),
     vue(),
  ],
});

I'm not sure if this is an issue specific to the Astro-Netlify-CMS integration, or if it's on the Astro / Astro Vue integration side of things. However, it was difficult to figure out the cause other than that it having occurred after setting up Astro-Netlify-CMS.

In case it helps to identify the source, here's the error messages I was getting.

When rendering Vue components without a client directive:

[plugin:vite:vue] Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<)

When they are passed a client:only directive:

Vue warn: Component is missing template or render function

Perhaps it's worth mentioning in the installation / config instructions that this can be resolved by declaring the Astro-Netlify-CMS integration prior to Vue.

@kcole93
Copy link
Author

kcole93 commented Sep 4, 2022

Here's a minimal reproduction on Stackblitz

@delucis
Copy link
Owner

delucis commented Sep 5, 2022

Thanks for the detailed bug report @kcole93!

I'm wondering if this is due to this integration also installing @astrojs/react. 🤔 I'll try to take a look this week to see what's going on.

@yacosta738
Copy link

I have the same issue with Vue components

bitmoji

@kcole93
Copy link
Author

kcole93 commented Oct 5, 2022

Hi Chris, just a heads up that someone else in the Astro discord came across a similar issue with weird Vue errors that were fixed when the order of declaring Vue in astro.config.mjs is changed, so I think it's safe to say that the issue doesn't rest with the NetlifyCMS integration.

See Issue 4994 in the Astro repo.

@delucis
Copy link
Owner

delucis commented Oct 6, 2022

Thanks for the heads up @kcole93 — appreciate it! In that case I think we can close this issue.

If anyone else finds themselves here, looking for a quick solution: try moving vue() after NetlifyCMS() in your integrations array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants