Skip to content

Commit

Permalink
fix(typescript): avoid including router file when router is not selected
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 30, 2018
1 parent 970eee7 commit 4d00161
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
extend: '@vue/cli-service/generator/router/template/src/views/Home.vue'
when: 'rootOptions.router'
replace:
- !!js/regexp /Welcome to Your Vue\.js App/
- !!js/regexp /<script>[^]*?<\/script>/
Expand Down
7 changes: 7 additions & 0 deletions packages/@vue/cli/lib/GeneratorAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ function renderFile (name, data, ejsOptions) {
finalTemplate = finalTemplate.replace(parsed.replace, content.trim())
}
}
if (parsed.when) {
finalTemplate = (
`<%_ if (${parsed.when}) { _%>` +
finalTemplate +
`<%_ } _%>`
)
}
}

return ejs.render(finalTemplate, data, ejsOptions)
Expand Down

0 comments on commit 4d00161

Please sign in to comment.