Skip to content

Commit

Permalink
feat(vue): add support vue devtools options (#11055)
Browse files Browse the repository at this point in the history
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
Co-authored-by: Jan-Niklas Wortmann <jan-niklas.wortmann@jetbrains.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
  • Loading branch information
4 people committed May 22, 2024
1 parent a687a17 commit b92de22
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 30 deletions.
21 changes: 21 additions & 0 deletions .changeset/sweet-needles-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"@astrojs/vue": minor
---

Updates the `devtools` type to allow passing `VueDevToolsOptions`

For more customization, you can pass options that the [Vue DevTools Vite Plugin](https://devtools-next.vuejs.org/guide/vite-plugin#options) supports. (Note: `appendTo` is not supported.) For example, you can set `launchEditor` to your preferred editor if you are not using Visual Studio Code:

```js title="astro.config.mjs"
import { defineConfig } from "astro/config";
import vue from "@astrojs/vue";

export default defineConfig({
// ...
integrations: [
vue({
devtools: { launchEditor: "webstorm" },
}),
],
});
```
2 changes: 1 addition & 1 deletion packages/integrations/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/compiler-sfc": "^3.4.27",
"vite-plugin-vue-devtools": "^7.1.3"
"vite-plugin-vue-devtools": "^7.2.0"
},
"devDependencies": {
"astro": "workspace:*",
Expand Down
7 changes: 5 additions & 2 deletions packages/integrations/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import type { Options as VueJsxOptions } from '@vitejs/plugin-vue-jsx';
import { MagicString } from '@vue/compiler-sfc';
import type { AstroIntegration, AstroRenderer, HookParameters } from 'astro';
import type { Plugin, UserConfig } from 'vite';
import type {VitePluginVueDevToolsOptions} from "vite-plugin-vue-devtools";

const VIRTUAL_MODULE_ID = 'virtual:@astrojs/vue/app';
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;

interface Options extends VueOptions {
jsx?: boolean | VueJsxOptions;
appEntrypoint?: string;
devtools?: boolean;
devtools?: boolean | Omit<VitePluginVueDevToolsOptions, "appendTo">;
}

function getRenderer(): AstroRenderer {
Expand Down Expand Up @@ -125,9 +126,11 @@ async function getViteConfiguration(

if (command === 'dev' && options?.devtools) {
const vueDevTools = (await import('vite-plugin-vue-devtools')).default;
const devToolsOptions = typeof options.devtools === 'object' ? options.devtools : {}
config.plugins?.push(
vueDevTools({
appendTo: VIRTUAL_MODULE_ID,
...devToolsOptions,
appendTo: VIRTUAL_MODULE_ID
})
);
}
Expand Down
47 changes: 20 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b92de22

Please sign in to comment.