File tree 6 files changed +78
-4
lines changed
generator/template-vue3/src
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 () => {
85
85
86
86
expect ( files [ 'src/main.js' ] ) . toMatch ( '.use(router)' )
87
87
88
+ expect ( files [ 'src/App.vue' ] ) . not . toMatch ( '<div id="app">' )
89
+
88
90
expect ( pkg . dependencies ) . toHaveProperty ( 'vue-router' )
89
91
expect ( pkg . dependencies [ 'vue-router' ] ) . toMatch ( '^4' )
90
92
} )
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 () => {
46
46
expect ( pkg ) . toHaveProperty ( [ 'devDependencies' , '@vue/compiler-sfc' ] )
47
47
48
48
expect ( files [ 'src/main.js' ] ) . toMatch ( `import { createApp } from 'vue'` )
49
+
50
+ expect ( files [ 'src/App.vue' ] ) . not . toMatch ( '<div id="app">' )
49
51
} )
Original file line number Diff line number Diff line change 1
1
module . exports = ( api , options ) => {
2
- const isVue3 = ( options . vueVersion === '3' )
3
2
api . render ( './template' , {
4
- isVue3,
5
3
doesCompile : api . hasPlugin ( 'babel' ) || api . hasPlugin ( 'typescript' )
6
4
} )
7
5
8
- if ( isVue3 ) {
6
+ if ( options . vueVersion === '3' ) {
9
7
api . extendPackage ( {
10
8
dependencies : {
11
9
'vue' : '^3.0.0-0'
Original file line number Diff line number Diff line change 1
1
<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 { _%>
2
10
<div id =" app" >
3
11
<img alt =" Vue logo" src =" ./assets/logo.png" >
4
12
<%_ if (!rootOptions.bare) { _%>
7
15
<h1 >Welcome to Your Vue.js App</h1 >
8
16
<%_ } _%>
9
17
</div >
18
+ <%_ } _%>
10
19
</template >
11
20
<%_ if (!rootOptions.bare ) { _%>
12
21
Original file line number Diff line number Diff line change 1
- < % _ if ( isVue3 ) { _ % >
1
+ < % _ if ( rootOptions . vueVersion === '3' ) { _ % >
2
2
import { createApp } from 'vue'
3
3
import App from './App.vue'
4
4
You can’t perform that action at this time.
0 commit comments