UNPKG

553 BJavaScriptView Raw
1import { resolve } from 'path'
2import { existsSync } from 'fs'
3
4export 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}