diff options
author | 2022-04-19 16:31:32 +0000 | |
---|---|---|
committer | 2022-04-19 16:31:32 +0000 | |
commit | 44e294c9cbaf8f6bbccce8b956c7c53d37c15c70 (patch) | |
tree | abdd607c391860ff7eee2798e3a79b03982edf51 /packages/integrations | |
parent | 550c7d0a94ca8809c83fc3c29c6a0f4a6cd4ffc5 (diff) | |
download | astro-44e294c9cbaf8f6bbccce8b956c7c53d37c15c70.tar.gz astro-44e294c9cbaf8f6bbccce8b956c7c53d37c15c70.tar.zst astro-44e294c9cbaf8f6bbccce8b956c7c53d37c15c70.zip |
Support custom vue compiler options in @astrojs/vue (#3143)
* adds support for passing options to @vitejs/plugin-vue
* updating vue integration README with options details
* adding a tests for custom vue compiler options
* chore: adding changeset
Diffstat (limited to 'packages/integrations')
-rw-r--r-- | packages/integrations/vue/README.md | 23 | ||||
-rw-r--r-- | packages/integrations/vue/src/index.ts | 9 |
2 files changed, 28 insertions, 4 deletions
diff --git a/packages/integrations/vue/README.md b/packages/integrations/vue/README.md index e9a55d3da..3d5baa70d 100644 --- a/packages/integrations/vue/README.md +++ b/packages/integrations/vue/README.md @@ -63,3 +63,26 @@ Also check our [Astro Integration Documentation][astro-integration] for more on [astro-integration]: https://docs.astro.build/en/guides/integrations-guide/ [astro-ui-frameworks]: https://docs.astro.build/en/core-concepts/framework-components/#using-framework-components + +## Options + +This integration is powered by `@vitejs/plugin-vue`. To customize the Vue compiler, options can be provided to the integration. See the `@vitejs/plugin-vue` [docs](https://github.com/vitejs/vite/tree/main/packages/plugin-vue) for more details. + +__astro.config.mjs__ + +```js +import vue from '@astrojs/vue'; + +export default { + // ... + integrations: [vue({ + template: { + compilerOptions: { + // treat any tag that starts with ion- as custom elements + isCustomElement: tag => tag.startsWith('ion-') + } + } + // ... + })], +} +```
\ No newline at end of file diff --git a/packages/integrations/vue/src/index.ts b/packages/integrations/vue/src/index.ts index 20adf0f66..b56763504 100644 --- a/packages/integrations/vue/src/index.ts +++ b/packages/integrations/vue/src/index.ts @@ -1,5 +1,6 @@ import type { AstroIntegration, AstroRenderer } from 'astro'; import vue from '@vitejs/plugin-vue'; +import type { Options } from '@vitejs/plugin-vue'; function getRenderer(): AstroRenderer { return { @@ -9,26 +10,26 @@ function getRenderer(): AstroRenderer { }; } -function getViteConfiguration() { +function getViteConfiguration(options?: Options) { return { optimizeDeps: { include: ['@astrojs/vue/client.js', 'vue'], exclude: ['@astrojs/vue/server.js'], }, - plugins: [vue()], + plugins: [vue(options)], ssr: { external: ['@vue/server-renderer'], }, }; } -export default function (): AstroIntegration { +export default function (options?: Options): AstroIntegration { return { name: '@astrojs/vue', hooks: { 'astro:config:setup': ({ addRenderer, updateConfig }) => { addRenderer(getRenderer()); - updateConfig({ vite: getViteConfiguration() }); + updateConfig({ vite: getViteConfiguration(options) }); }, }, }; |