File tree Expand file tree Collapse file tree 6 files changed +78
-4
lines changed
generator/template-vue3/src Expand file tree Collapse file tree 6 files changed +78
-4
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ test('use with Vue 3', async () => {
8585
8686 expect ( files [ 'src/main.js' ] ) . toMatch ( '.use(router)' )
8787
88+ expect ( files [ 'src/App.vue' ] ) . not . toMatch ( '<div id="app">' )
89+
8890 expect ( pkg . dependencies ) . toHaveProperty ( 'vue-router' )
8991 expect ( pkg . dependencies [ 'vue-router' ] ) . toMatch ( '^4' )
9092} )
Original file line number Diff line number Diff line change 1+ ---
2+ extend: '@vue/cli-service/generator/template/src/App.vue'
3+ replace:
4+ - !!js/regexp /<template >[^]*?<\/template>/
5+ - !!js/regexp /\n<script >[^ ]* ? < \/ script> \n/
6+ - !! js/ regexp / margin- top[^ ]* ? < \/ style> /
7+ -- -
8+
9+ < % # REPLACE % >
10+ < template>
11+ < div id= " nav" >
12+ < router- link to= " /" > Home< / router- link> |
13+ < router- link to= " /about" > About< / router- link>
14+ < / div>
15+ < router- view/ >
16+ < / template>
17+ < % # END_REPLACE % >
18+
19+ < % # REPLACE % >
20+ < % # END_REPLACE % >
21+
22+ < % # REPLACE % >
23+ }
24+
25+ < % _ if (rootOptions .cssPreprocessor !== ' stylus' ) { _% >
26+ < % _ if (! rootOptions .cssPreprocessor ) { _% >
27+ #nav {
28+ padding: 30px ;
29+ }
30+
31+ #nav a {
32+ font- weight: bold;
33+ color: #2c3e50 ;
34+ }
35+
36+ #nav a .router - link- exact- active {
37+ color: #42b983 ;
38+ }
39+ < % _ } else { _% >
40+ #nav {
41+ padding: 30px ;
42+
43+ a {
44+ font- weight: bold;
45+ color: #2c3e50 ;
46+
47+ & .router - link- exact- active {
48+ color: #42b983 ;
49+ }
50+ }
51+ }
52+ < % _ } _% >
53+ < % _ } else { _% >
54+ #nav
55+ padding 30px
56+ a
57+ font- weight bold
58+ color #2c3e50
59+ & .router - link- exact- active
60+ color #42b983
61+ < % _ } _% >
62+ < / style>
63+ < % # END_REPLACE % >
Original file line number Diff line number Diff line change @@ -46,4 +46,6 @@ test('Vue 3', async () => {
4646 expect ( pkg ) . toHaveProperty ( [ 'devDependencies' , '@vue/compiler-sfc' ] )
4747
4848 expect ( files [ 'src/main.js' ] ) . toMatch ( `import { createApp } from 'vue'` )
49+
50+ expect ( files [ 'src/App.vue' ] ) . not . toMatch ( '<div id="app">' )
4951} )
Original file line number Diff line number Diff line change 11module . exports = ( api , options ) => {
2- const isVue3 = ( options . vueVersion === '3' )
32 api . render ( './template' , {
4- isVue3,
53 doesCompile : api . hasPlugin ( 'babel' ) || api . hasPlugin ( 'typescript' )
64 } )
75
8- if ( isVue3 ) {
6+ if ( options . vueVersion === '3' ) {
97 api . extendPackage ( {
108 dependencies : {
119 'vue' : '^3.0.0-0'
Original file line number Diff line number Diff line change 11<template >
2+ <%_ if (rootOptions.vueVersion === '3') { _%>
3+ <img alt =" Vue logo" src =" ./assets/logo.png" >
4+ <%_ if (!rootOptions.bare) { _%>
5+ <HelloWorld msg =" Welcome to Your Vue.js App" />
6+ <%_ } else { _%>
7+ <h1 >Welcome to Your Vue.js App</h1 >
8+ <%_ } _%>
9+ <%_ } else { _%>
210 <div id =" app" >
311 <img alt =" Vue logo" src =" ./assets/logo.png" >
412 <%_ if (!rootOptions.bare) { _%>
715 <h1 >Welcome to Your Vue.js App</h1 >
816 <%_ } _%>
917 </div >
18+ <%_ } _%>
1019</template >
1120<%_ if (!rootOptions.bare ) { _%>
1221
Original file line number Diff line number Diff line change 1- < % _ if ( isVue3 ) { _ % >
1+ < % _ if ( rootOptions . vueVersion === '3' ) { _ % >
22import { createApp } from 'vue'
33import App from './App.vue'
44
You can’t perform that action at this time.
0 commit comments