11import * as fs from 'node:fs'
22import * as path from 'path'
33
4- function getBareBoneAppContent ( isTs : boolean ) {
5- return `<script setup${ isTs ? ' lang="ts"' : '' } >
6- </script>
7-
8- <template>
9- <h1>Hello World</h1>
10- </template>
11-
12- <style scoped>
13- </style>
14- `
15- }
16-
174function replaceContent ( filepath : string , replacer : ( content : string ) => string ) {
185 const content = fs . readFileSync ( filepath , 'utf8' )
196 fs . writeFileSync ( filepath , replacer ( content ) )
@@ -24,17 +11,15 @@ export default function trimBoilerplate(rootDir: string, features: Record<string
2411 const srcDir = path . resolve ( rootDir , 'src' )
2512
2613 for ( const filename of fs . readdirSync ( srcDir ) ) {
27- // Keep `App.vue`, `main.js/ts`, `router`, and `stores` directories
28- if ( [ 'App.vue' , 'main.js' , 'main.ts' , 'router' , 'stores' ] . includes ( filename ) ) {
14+ // Keep `main.js/ts`, `router`, and `stores` directories
15+ // `App.vue` would be re-rendered in the next step
16+ if ( [ 'main.js' , 'main.ts' , 'router' , 'stores' ] . includes ( filename ) ) {
2917 continue
3018 }
3119 const fullpath = path . resolve ( srcDir , filename )
3220 fs . rmSync ( fullpath , { recursive : true } )
3321 }
3422
35- // Replace the content in `src/App.vue` with a barebone template
36- replaceContent ( path . resolve ( rootDir , 'src/App.vue' ) , ( ) => getBareBoneAppContent ( isTs ) )
37-
3823 // Remove CSS import in the entry file
3924 const entryPath = path . resolve ( rootDir , isTs ? 'src/main.ts' : 'src/main.js' )
4025 replaceContent ( entryPath , ( content ) => content . replace ( "import './assets/main.css'\n\n" , '' ) )
0 commit comments