@@ -63,18 +63,22 @@ export default {
63
63
* @argument : this.componentMap['App'].children
64
64
*/
65
65
createRouterImports (appChildren ) {
66
- let str = " import { createRouter, createWebHistory } from 'vue-router'\n " ;
66
+ let str = " import { createRouter, createWebHistory } from 'vue-router'; \n " ;
67
67
appChildren .forEach ((child ) => {
68
- str += ` import ${ child} from './views/${ child} .vue'\n ` ;
68
+ str += ` import ${ child} from './views/${ child} .vue'; \n ` ;
69
69
});
70
70
return str;
71
71
},
72
72
/**
73
73
* @description creates the `export default` code in <script>
74
74
*/
75
75
createExport (appChildren ) {
76
- let str =
77
- " export default createRouter({\n\t history: createWebHistory(),\n\t base: process.env.BASE_URL,\n\t routes: [\n " ;
76
+ let str;
77
+ if (this .exportAsTypescript === ' on' ) {
78
+ str = " export default createRouter({\n\t history: createWebHistory(process.env.BASE_URL),\n\t routes: [\n " ;
79
+ } else {
80
+ str = " export default createRouter({\n\t history: createWebHistory(),\n\t base: process.env.BASE_URL,\n\t routes: [\n " ;
81
+ }
78
82
appChildren .forEach ((child ) => {
79
83
if (child === " HomeView" ) {
80
84
str += ` \t\t {\n\t\t\t path: '/',\n\t\t\t name:'${ child} ',\n\t\t\t component:${ child} \n\t\t },\n ` ;
@@ -339,11 +343,11 @@ export default {
339
343
},
340
344
// creates main.js boilerplate
341
345
createMainFile (location ) {
342
- let str = ` import { createApp } from 'vue'` ;
343
- str += ` \n import App from './App.vue'` ;
344
- str += ` \n import router from './router'` ;
346
+ let str = ` import { createApp } from 'vue'; ` ;
347
+ str += ` \n import App from './App.vue'; ` ;
348
+ str += ` \n import router from './router'; ` ;
345
349
// str += `\n\n import './index.css'`
346
- str += ` \n\n const app = createApp(App)` ;
350
+ str += ` \n\n const app = createApp(App); ` ;
347
351
// str += `\n\trouter,
348
352
str += ` \n app.use(router);` ;
349
353
str += ` \n app.mount('#app');` ;
@@ -370,14 +374,7 @@ export default {
370
374
},
371
375
createTSConfig (location ) {
372
376
if (this .exportAsTypescript === " on" ) {
373
- let str = ` {\n\t "extends": "@vue/tsconfig/tsconfig.web.json",
374
- "include": ["src/**/*", "src/**/*.vue"],
375
- "compilerOptions": {
376
- "baseUrl": ".",
377
- "paths": {
378
- "@/*": ["./src/*"]
379
- }
380
- },\n }` ;
377
+ let str = ` {\n\t "extends": "@vue/tsconfig/tsconfig.web.json",\n\t "include": ["src/**/*", "src/**/*.vue"],\n\t "compilerOptions": {\n\t\t "baseUrl": ".",\n\t\t "paths": {\n\t\t\t "@/*": ["./src/*"]\n\t\t }\n\t }\n }` ;
381
378
fs .writeFileSync (path .join (location, " tsconfig.json" ), str);
382
379
} else {
383
380
return ;
@@ -406,9 +403,9 @@ export default {
406
403
str += ` \n\t\t "babel-eslint": "^10.0.1",` ;
407
404
str += ` \n\t\t "eslint": "^6.7.2",` ;
408
405
str += ` \n\t\t "eslint-plugin-vue": "^7.0.0-0",` ;
409
- str += ` \n\t\t "@vue/compiler-sfc": "^3.0.0-0", ` ;
406
+ str += ` \n\t\t "@vue/compiler-sfc": "^3.0.0-0"` ;
410
407
if (this .exportAsTypescript === " on" ) {
411
- str += ` \n\t\t "@vue/tsconfig": "^0.1.3",` ;
408
+ str += ` , \n\t\t "@vue/tsconfig": "^0.1.3",` ;
412
409
str += ` \n\t\t "typescript": "~4.5.5",` ;
413
410
str += ` \n\t\t "vue-tsc": "^0.31.4",` ;
414
411
str += ` \n\t\t "@babel/preset-typescript": "^7.16.7"` ; // not sure we need this?
0 commit comments