Skip to content

Commit

Permalink
feat(vue): add support for launchEditor in devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Niklas Wortmann committed May 15, 2024
1 parent 1df24a4 commit ca888f0
Show file tree
Hide file tree
Showing 3 changed files with 8,179 additions and 6,308 deletions.
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
5 changes: 4 additions & 1 deletion 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 | {launchEditor: VitePluginVueDevToolsOptions['launchEditor'];};
}

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 launchEditor = typeof options.devtools === 'object' ? options.devtools.launchEditor : "code"
config.plugins?.push(
vueDevTools({
appendTo: VIRTUAL_MODULE_ID,
launchEditor
})
);
}
Expand Down
Loading

0 comments on commit ca888f0

Please sign in to comment.