@@ -200,7 +200,7 @@ const openReactEditor = async (code: string, options?: EditorOptions) => {
200
200
}
201
201
202
202
const openVueEditor = async ( code : string , options ?: EditorOptions ) => {
203
- let [ package_json , package_lock_json , index_html , variables_css , vite_config_ts , main_ts , app_vue , tsconfig_json , tsconfig_node_json , env_d_ts ] = await loadSourceFiles ( [
203
+ const defaultFiles = await loadSourceFiles ( [
204
204
'vue/package.json' ,
205
205
'vue/package-lock.json' ,
206
206
'vue/index.html' ,
@@ -213,7 +213,28 @@ const openVueEditor = async (code: string, options?: EditorOptions) => {
213
213
'vue/env.d.ts'
214
214
] , options . version ) ;
215
215
216
- main_ts = main_ts . replace ( '{{ MODE }}' , options ?. mode ) ;
216
+ const mainTs = 'src/main.ts' ;
217
+ const files = {
218
+ 'src/App.vue' : defaultFiles [ 6 ] ,
219
+ 'src/components/Example.vue' : code ,
220
+ [ mainTs ] : defaultFiles [ 5 ] ,
221
+ 'src/env.d.ts' : defaultFiles [ 9 ] ,
222
+ 'src/theme/variables.css' : defaultFiles [ 3 ] ,
223
+ 'index.html' : defaultFiles [ 2 ] ,
224
+ 'vite.config.ts' : defaultFiles [ 4 ] ,
225
+ 'package.json' : defaultFiles [ 0 ] ,
226
+ 'package-lock.json' : defaultFiles [ 1 ] ,
227
+ 'tsconfig.json' : defaultFiles [ 7 ] ,
228
+ 'tsconfig.node.json' : defaultFiles [ 8 ] ,
229
+ ...options ?. files ,
230
+ '.stackblitzrc' : `{
231
+ "startCommand": "yarn run dev"
232
+ }`
233
+ } ;
234
+
235
+ files [ mainTs ] = files [ mainTs ] . replace ( '.use(IonicVue)' , `.use(IonicVue, {
236
+ mode: '${ options ?. mode } '
237
+ })` ) ;
217
238
218
239
/**
219
240
* We have to use Stackblitz web containers here (node template), due
@@ -225,23 +246,7 @@ const openVueEditor = async (code: string, options?: EditorOptions) => {
225
246
template : 'node' ,
226
247
title : options ?. title ?? DEFAULT_EDITOR_TITLE ,
227
248
description : options ?. description ?? DEFAULT_EDITOR_DESCRIPTION ,
228
- files : {
229
- 'src/App.vue' : app_vue ,
230
- 'src/components/Example.vue' : code ,
231
- 'src/main.ts' : main_ts ,
232
- 'src/env.d.ts' : env_d_ts ,
233
- 'src/theme/variables.css' : variables_css ,
234
- 'index.html' : index_html ,
235
- 'vite.config.ts' : vite_config_ts ,
236
- 'package.json' : package_json ,
237
- 'package-lock.json' : package_lock_json ,
238
- 'tsconfig.json' : tsconfig_json ,
239
- 'tsconfig.node.json' : tsconfig_node_json ,
240
- ...options ?. files ,
241
- '.stackblitzrc' : `{
242
- "startCommand": "yarn run dev"
243
- }`
244
- }
249
+ files
245
250
} ) ;
246
251
}
247
252
0 commit comments