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

feat(vue): add support vue devtools options #11055

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading