1
1
<script setup lang="ts">
2
- import type { OutputModes } from ' @vue/repl'
2
+ import type { OutputModes , SFCOptions } from ' @vue/repl'
3
3
import type { ShallowRef } from ' vue'
4
4
import { mergeImportMap , Repl , useStore , useVueImportMap } from ' @vue/repl'
5
5
import MonacoEditor from ' @vue/repl/monaco-editor'
@@ -73,6 +73,16 @@ const theme = computed(() => {
73
73
})
74
74
75
75
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
+ },
76
86
headHTML: `
77
87
<script src="https://cdn.jsdelivr.net/npm/@unocss/runtime"><\/ script>
78
88
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unocss/reset/tailwind.min.css" />
@@ -85,6 +95,27 @@ const previewOptions = {
85
95
` ,
86
96
}
87
97
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
+
88
119
const store = useStore (
89
120
{
90
121
// pre-set import map
@@ -96,6 +127,7 @@ const store = useStore(
96
127
// and default to the "preview" tab
97
128
outputMode ,
98
129
template ,
130
+ sfcOptions ,
99
131
},
100
132
// initialize repl with previously serialized state
101
133
hash .value ?? undefined ,
0 commit comments