1 | import { resolve } from 'path'
|
2 | import { existsSync } from 'fs'
|
3 |
|
4 | export default function () {
|
5 | const routerPath = resolve(this.options.srcDir, 'router.js')
|
6 |
|
7 | // Check if router.js is defined
|
8 | if (!existsSync(routerPath)) throw new Error('[nuxt-router-module] Please create a router.js file in your source folder.')
|
9 |
|
10 | // Disable parsing `pages/`
|
11 | this.nuxt.options.build.createRoutes = () => {
|
12 | return []
|
13 | }
|
14 |
|
15 | // Add ${srcDir}/router.js as the main template for routing
|
16 | this.addTemplate({
|
17 | fileName: 'router.js',
|
18 | src: routerPath
|
19 | })
|
20 | }
|