Ajouter Vuetify à Astro : un guide étape par étape
P粉676821490
P粉676821490 2023-12-19 09:35:08
0
1
582

J'ai du mal à ajouter Vuetify 3 à Astro en utilisant l'intégration Vue. Voici ce que j'ai jusqu'à présent :

import { defineConfig } from 'astro/config';

import vue from '@astrojs/vue';

import vuetify from 'vite-plugin-vuetify';

// https://astro.build/config
export default defineConfig({
  integrations: [vue()],
  vite: {
    ssr: {
      noExternal: ['vuetify'],
    },
    plugins: [vuetify()],
  },
});

Je reçois 'Vuetify 插件必须在 vue 插件之后加载' erreur. Je ne sais pas comment passer à autre chose à partir d'ici. Je suis ouvert à toutes suggestions.

P粉676821490
P粉676821490

répondre à tous(1)
P粉964682904

Configuration dans Astro Integration ( @astrojs/vue 在本例中)被附加到您自己的 Astro 配置中,因此 vuetify Le plugin sera enregistré ici en premier.

La solution consiste à définir votre propre Intégration Astro, en appelant updateConfig() Ajouter une validation :

// astro.config.mjs
import vuetifyPlugin from 'vite-plugin-vuetify';

/**
 * Vuetify integration for Astro
 * @param {import('astro/config').Options} options
 * @returns {import('astro/config').AstroIntegration}
 */
function vuetify(options) {
  return {
    name: 'my-astro-vuetify-integration',
    hooks: {
      'astro:config:setup': ({ updateConfig }) => {
        updateConfig({
          vite: {
            ssr: {
              noExternal: ['vuetify'],
            },
            plugins: [vuetifyPlugin()],
          },
        });
      },
    },
  }
}

Et installez-le après l'intégration de Vue  :

// astro.config.mjs
export default defineConfig({
  integrations: [
    vue(),
    vuetify(),
  ],
})
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!