Skip to content
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

Custom router in .nuxt folder #107

Open
Kolobok12309 opened this issue Sep 17, 2021 · 2 comments
Open

Custom router in .nuxt folder #107

Kolobok12309 opened this issue Sep 17, 2021 · 2 comments

Comments

@Kolobok12309
Copy link

Kolobok12309 commented Sep 17, 2021

  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
    routerFilePath: relative(this.options.buildDir, routerFilePath).replace(/\/+|\\+/g, '/'),

    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
    if (!existsSync(routerFilePath)) {

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

@vis97c
Copy link

vis97c commented Dec 20, 2021

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

@Kolobok12309
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants