The ignore property

Define the ignore files for your Nuxt application


.nuxtignore

You can use a .nuxtignore file to let Nuxt ignore layout, page, store and middleware files in your project’s root directory (rootDir) during the build phase. The .nuxtignore file is subject to the same specification as .gitignore and .eslintignore files, in which each line is a glob pattern indicating which files should be ignored.

For example:

  1. # ignore layout foo.vue
  2. layouts/foo.vue
  3. # ignore layout files whose name ends with -ignore.vue
  4. layouts/*-ignore.vue
  5. # ignore page bar.vue
  6. pages/bar.vue
  7. # ignore page inside ignore folder
  8. pages/ignore/*.vue
  9. # ignore store baz.js
  10. store/baz.js
  11. # ignore store files match *.test.*
  12. store/ignore/*.test.*
  13. # ignore middleware files under foo folder except foo/bar.js
  14. middleware/foo/*.js
  15. !middleware/foo/bar.js

More details about the spec are in gitignore doc

The ignorePrefix Property

  • Type: String
  • Default: '-'

Any file in pages/, layouts/, middleware/ or store/ will be ignored during building if its filename starts with the prefix specified by ignorePrefix.

By default all files which start with - will be ignored, such as store/-foo.js and pages/-bar.vue. This allows for co-locating tests, utilities, and components with their callers without themselves being converted into routes, stores, etc.

The ignore Property

  • Type: Array
  • Default: ['**/*.test.*']

More customizable than ignorePrefix: all files matching glob patterns specified inside ignore will be ignored in building.

ignoreOptions

nuxtignore is using node-ignore under the hood, ignoreOptions can be configured as options of node-ignore.

nuxt.config.js

  1. export default {
  2. ignoreOptions: {
  3. ignorecase: false
  4. }
  5. }