diff --git a/packages/sfc-playground/src/App.vue b/packages/sfc-playground/src/App.vue index 4b62519ce6e..7a9561183a9 100644 --- a/packages/sfc-playground/src/App.vue +++ b/packages/sfc-playground/src/App.vue @@ -12,7 +12,7 @@ const setVH = () => { window.addEventListener('resize', setVH) setVH() -const useSSRMode = ref(false) +const useSSRMode = ref(false) const { productionMode, vueVersion, importMap } = useVueImportMap({ runtimeDev: import.meta.env.PROD @@ -71,6 +71,20 @@ const store = useStore( // @ts-expect-error globalThis.store = store +let { mainFile } = store + +if (mainFile === 'src/App.vue') { + const firstFile = Object.keys(store.getFiles())[0] + if (['index.html', 'main.js', 'main.ts'].includes(firstFile)) { + mainFile = `src/${firstFile}` + store.setFiles(store.getFiles(), mainFile) + } +} + +if (!mainFile.endsWith('.vue')) { + useSSRMode.value = null +} + // persist state watchEffect(() => { const newHash = store @@ -121,7 +135,7 @@ onMounted(() => { :editor="Monaco" @keydown.ctrl.s.prevent @keydown.meta.s.prevent - :ssr="useSSRMode" + :ssr="useSSRMode === true" :store="store" :showCompileOutput="true" :autoResize="true" diff --git a/packages/sfc-playground/src/Header.vue b/packages/sfc-playground/src/Header.vue index 6506ad7bab2..127fa40b0d3 100644 --- a/packages/sfc-playground/src/Header.vue +++ b/packages/sfc-playground/src/Header.vue @@ -13,7 +13,7 @@ import VersionSelect from './VersionSelect.vue' const props = defineProps<{ store: ReplStore prod: boolean - ssr: boolean + ssr: boolean | null }>() const emit = defineEmits([ 'toggle-theme', @@ -100,6 +100,7 @@ function toggleDark() { {{ prod ? 'PROD' : 'DEV' }}