-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow router/vuex to be late added via
vue add
- Loading branch information
Showing
10 changed files
with
82 additions
and
30 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/@vue/cli-plugin-typescript/generator/template/src/views/Home.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = (api, options) => { | ||
api.injectImports(`src/main.js`, `import router from './router'`) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
api.injectRootOptions(`src/main.js`, `router`) | ||
api.extendPackage({ | ||
dependencies: { | ||
'vue-router': '^3.0.1' | ||
} | ||
}) | ||
api.render('./template') | ||
|
||
if (options.invoking) { | ||
api.postProcessFiles(files => { | ||
const appFile = files[`src/App.vue`] | ||
if (appFile) { | ||
files[`src/App.vue`] = appFile.replace(/^<template>[^]+<\/script>/, ` | ||
<template> | ||
<div id="app"> | ||
<div id="nav"> | ||
<router-link to="/">Home</router-link> | | ||
<router-link to="/about">About</router-link> | ||
</div> | ||
<router-view/> | ||
</div> | ||
</template> | ||
`.trim()) | ||
console.log(files[`src/App.vue`]) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
...ce/generator/template/src/views/About.vue → ...rator/router/template/src/views/About.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<%_ if (rootOptions.router) { _%> | ||
<template> | ||
<div class="about"> | ||
<h1>This is an about page</h1> | ||
</div> | ||
</template> | ||
<%_ } _%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = (api, options) => { | ||
api.injectImports(`src/main.js`, `import store from './store'`) | ||
api.injectRootOptions(`src/main.js`, `store`) | ||
api.extendPackage({ | ||
dependencies: { | ||
vuex: '^3.0.1' | ||
} | ||
}) | ||
api.render('./template') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@yyx990803 Maybe we need a ternary for
main.ts
here?