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 3 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 a boolean or `VueDevToolsOptions`. This is useful to set `launchEditor` if you're not using Visual Studio Code for example:

```js
import { defineConfig } from "astro/config"
import vue from "@astrojs/vue"

export default defineConfig({
integrations: [
vue({
// devtools: true is equivalent to {}
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 pluginOptions = typeof options.devtools === 'object' ? options.devtools : {}
florian-lefebvre marked this conversation as resolved.
Show resolved Hide resolved
config.plugins?.push(
vueDevTools({
appendTo: VIRTUAL_MODULE_ID,
...pluginOptions,
appendTo: VIRTUAL_MODULE_ID
})
);
}
Expand Down
Loading
Loading