8000 Make router a separate plugin by pksunkara · Pull Request #4196 · vuejs/vue-cli · GitHub
[go: up one dir, main page]

Skip to content

Make router a separate plugin #4196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: change src/router.js for most common use cases
  • Loading branch information
pksunkara committed Jul 5, 2019
commit 3cc5e04f4f69b7ba3a1de72f9bb554d51ff09254
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ test('base', async () => {
options: {}
})

expect(files['src/router.js']).toBeTruthy()
expect(files['src/router.js']).not.toMatch('history')
expect(files['src/router/index.js']).toBeTruthy()
expect(files['src/router/index.js']).not.toMatch('history')
expect(files['src/views/About.vue']).toBeTruthy()
expect(files['src/views/Home.vue']).toBeTruthy()
expect(files['src/App.vue']).toMatch('<router-link to="/">Home</router-link>')
Expand All @@ -28,8 +28,8 @@ test('history mode', async () => {
}
})

expect(files['src/router.js']).toBeTruthy()
expect(files['src/router.js']).toMatch('history')
expect(files['src/router/index.js']).toBeTruthy()
expect(files['src/router/index.js']).toMatch('history')
expect(files['src/views/About.vue']).toBeTruthy()
expect(files['src/views/Home.vue']).toBeTruthy()
expect(files['src/App.vue']).toMatch('<router-link to="/">Home</router-link>')
Expand All @@ -53,8 +53,8 @@ test('use with Babel', async () => {
}
])

expect(files['src/router.js']).toBeTruthy()
expect(files['src/router.js']).toMatch('component: () => import')
expect(files['src/router/index.js']).toBeTruthy()
expect(files['src/router/index.js']).toMatch('component: () => import')
expect(files['src/views/About.vue']).toBeTruthy()
expect(files['src/views/Home.vue']).toBeTruthy()
expect(files['src/App.vue']).toMatch('<router-link to="/">Home</router-link>')
Expand Down
33 changes: 0 additions & 33 deletions packages/@vue/cli-plugin-router/generator/template/src/router.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
<%_ if (doesCompile) { _%>
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
<%_ } else { _%>
component: function () {
return import(/* webpackChunkName: "about" */ '../views/About.vue')
}
<%_ } _%>
}
]

const router = new VueRouter({
<%_ if (historyMode) { _%>
mode: 'history',
base: process.env.BASE_URL,
<%_ } _%>
routes
})

export default router
0