astro/packages/integrations/vue/src/index.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
947 B
TypeScript
Raw Normal View History

import type { Options } from '@vitejs/plugin-vue';
2022-09-06 15:12:47 +00:00
import vue from '@vitejs/plugin-vue';
2022-06-06 16:49:53 +00:00
import type { AstroIntegration, AstroRenderer } from 'astro';
import type { UserConfig } from 'vite';
function getRenderer(): AstroRenderer {
return {
name: '@astrojs/vue',
clientEntrypoint: '@astrojs/vue/client.js',
serverEntrypoint: '@astrojs/vue/server.js',
};
}
function getViteConfiguration(options?: Options): UserConfig {
return {
optimizeDeps: {
include: ['@astrojs/vue/client.js', 'vue'],
exclude: ['@astrojs/vue/server.js'],
},
plugins: [vue(options)],
ssr: {
external: ['@vue/server-renderer'],
2022-09-06 15:12:47 +00:00
noExternal: ['vueperslides'],
},
};
}
export default function (options?: Options): AstroIntegration {
return {
name: '@astrojs/vue',
hooks: {
'astro:config:setup': ({ addRenderer, updateConfig }) => {
addRenderer(getRenderer());
updateConfig({ vite: getViteConfiguration(options) });
},
},
};
}