Skip to content
Advertisement

How to ignore a .ts/.js file in nuxt to not be generated in routes?

i’m new to nuxt.js and also trying to set a small architecture to my project.

i want to set my components like this:

pages/
  componentName/
     index.vue
     componentName.ts
     componentName.scss

the issue is when nuxt generate routes, i got:

/componentName 
/componentName/componentName

and the second route based on .ts file, i did change my .ts file to see if there’s any changes, and yes the second componentName changes to match .ts file name.

and i don’t know how to to ignore .ts files when nuxt generating routes.

Thanks

Answer

You can use the `.nuxtignore’ file to ignore files or extensions with Nuxt. To ignore all .ts files within componentName use this in your .nuxtignore file:

pages/componentName/*.ts

You can read more here: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-ignore

Advertisement