Skip to content

Custom router in .nuxt folder #107

Open
@Kolobok12309

Description

@Kolobok12309
  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions