router-module icon indicating copy to clipboard operation
router-module copied to clipboard

Custom router in .nuxt folder

Open Kolobok12309 opened this issue 4 years ago • 2 comments

  1. If i add custom router in .nuxt folder, this fragment create relative link, but for .nuxt folder it hasn't dot prefix, for example path to .nuxt/custom-router.js is custom-router.js, webpack try find package https://github.com/nuxt-community/router-module/blob/18bb2d39b55a9da8abec0a10a9f4552291dc0b39/src/module.ts#L50 Example:
['@nuxtjs/router', {
  keepDefaultRouter: true,
  path: path.resolve(__dirname, './.nuxt'),
  fileName: 'cache-router.js',
}],
  1. I can't create custom-router.js before @nuxtjs/router check is file exist. Simple module.addTemplate worked only for second time (first time generate file) and writeFileSync create file before nuxt generate files, therefore nuxt delete it. Only one worked variant is generate file with writeFileSync in srcDir https://github.com/nuxt-community/router-module/blob/18bb2d39b55a9da8abec0a10a9f4552291dc0b39/src/module.ts#L40

Examples of module that overwrite router madhusudanbabar/k-domains and

https://github.com/Kolobok12309/vue-router-webcache/blob/f5411bc54e72efcd78f5ec8153b4a52965f80515/lib/nuxt/index.ts#L40-L46

Kolobok12309 avatar Sep 17 '21 18:09 Kolobok12309

@Kolobok12309 why are you trying to add your custom router on a dinamically created route?

vis97c avatar Dec 20 '21 17:12 vis97c

@vis97c, to add some functionality from nuxt modules, for example my small package for enable vue-router working in webcache

Kolobok12309 avatar Dec 20 '21 17:12 Kolobok12309