Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ test('use with Vue 3', async () => {

expect(files['src/main.js']).toMatch('.use(router)')

expect(files['src/App.vue']).not.toMatch('<div id="app">')

expect(pkg.dependencies).toHaveProperty('vue-router')
expect(pkg.dependencies['vue-router']).toMatch('^4')
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
extend: '@vue/cli-service/generator/template/src/App.vue'
replace:
- !!js/regexp /<template>[^]*?<\/template>/
- !!js/regexp /\n<script>[^]*?<\/script>\n/
- !!js/regexp / margin-top[^]*?<\/style>/
---

<%# REPLACE %>
<template>
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</template>
<%# END_REPLACE %>

<%# REPLACE %>
<%# END_REPLACE %>

<%# REPLACE %>
}

<%_ if (rootOptions.cssPreprocessor !== 'stylus') { _%>
<%_ if (!rootOptions.cssPreprocessor) { _%>
#nav {
padding: 30px;
}

#nav a {
font-weight: bold;
color: #2c3e50;
}

#nav a.router-link-exact-active {
color: #42b983;
}
<%_ } else { _%>
#nav {
padding: 30px;

a {
font-weight: bold;
color: #2c3e50;

&.router-link-exact-active {
color: #42b983;
}
}
}
<%_ } _%>
<%_ } else { _%>
#nav
padding 30px
a
font-weight bold
color #2c3e50
&.router-link-exact-active
color #42b983
<%_ } _%>
</style>
<%# END_REPLACE %>
2 changes: 2 additions & 0 deletions packages/@vue/cli-service/__tests__/generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ test('Vue 3', async () => {
expect(pkg).toHaveProperty(['devDependencies', '@vue/compiler-sfc'])

expect(files['src/main.js']).toMatch(`import { createApp } from 'vue'`)

expect(files['src/App.vue']).not.toMatch('<div id="app">')
})
4 changes: 1 addition & 3 deletions packages/@vue/cli-service/generator/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module.exports = (api, options) => {
const isVue3 = (options.vueVersion === '3')
api.render('./template', {
isVue3,
doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript')
})

if (isVue3) {
if (options.vueVersion === '3') {
api.extendPackage({
dependencies: {
'vue': '^3.0.0-0'
Expand Down
9 changes: 9 additions & 0 deletions packages/@vue/cli-service/generator/template/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<template>
<%_ if (rootOptions.vueVersion === '3') { _%>
<img alt="Vue logo" src="./assets/logo.png">
<%_ if (!rootOptions.bare) { _%>
<HelloWorld msg="Welcome to Your Vue.js App"/>
<%_ } else { _%>
<h1>Welcome to Your Vue.js App</h1>
<%_ } _%>
<%_ } else { _%>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<%_ if (!rootOptions.bare) { _%>
Expand All @@ -7,6 +15,7 @@
<h1>Welcome to Your Vue.js App</h1>
<%_ } _%>
</div>
<%_ } _%>
</template>
<%_ if (!rootOptions.bare) { _%>

Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/generator/template/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%_ if (isVue3) { _%>
<%_ if (rootOptions.vueVersion === '3') { _%>
import { createApp } from 'vue'
import App from './App.vue'

Expand Down