Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 132ba63

Browse filesBrowse files
committed
feat: port some sfc options from vue playground
1 parent 36a796e commit 132ba63
Copy full SHA for 132ba63

File tree

Expand file treeCollapse file tree

1 file changed

+33
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+33
-1
lines changed

‎app/pages/index.vue

Copy file name to clipboardExpand all lines: app/pages/index.vue
+33-1Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import type { OutputModes } from '@vue/repl'
2+
import type { OutputModes, SFCOptions } from '@vue/repl'
33
import type { ShallowRef } from 'vue'
44
import { mergeImportMap, Repl, useStore, useVueImportMap } from '@vue/repl'
55
import MonacoEditor from '@vue/repl/monaco-editor'
@@ -73,6 +73,16 @@ const theme = computed(() => {
7373
})
7474
7575
const previewOptions = {
76+
customCode: {
77+
importCode: `import { initCustomFormatter } from 'vue'`,
78+
useCode: `if (window.devtoolsFormatters) {
79+
const index = window.devtoolsFormatters.findIndex((v) => v.__vue_custom_formatter)
80+
window.devtoolsFormatters.splice(index, 1)
81+
initCustomFormatter()
82+
} else {
83+
initCustomFormatter()
84+
}`,
85+
},
7686
headHTML: `
7787
<script src="https://cdn.jsdelivr.net/npm/@unocss/runtime"><\/script>
7888
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unocss/reset/tailwind.min.css" />
@@ -85,6 +95,27 @@ const previewOptions = {
8595
`,
8696
}
8797
98+
// enable experimental features
99+
const sfcOptions = computed<SFCOptions>(
100+
() => ({
101+
script: {
102+
inlineTemplate: productionMode.value,
103+
isProd: productionMode.value,
104+
propsDestructure: true,
105+
},
106+
style: {
107+
isProd: productionMode.value,
108+
},
109+
template: {
110+
isProd: productionMode.value,
111+
compilerOptions: {
112+
isCustomElement: (tag: string) =>
113+
tag.startsWith('custom-'),
114+
},
115+
},
116+
}),
117+
)
118+
88119
const store = useStore(
89120
{
90121
// pre-set import map
@@ -96,6 +127,7 @@ const store = useStore(
96127
// and default to the "preview" tab
97128
outputMode,
98129
template,
130+
sfcOptions,
99131
},
100132
// initialize repl with previously serialized state
101133
hash.value ?? undefined,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.