Repository: nuxt/nuxt.js
Pull request #7132 (2020-03-25 21:58:59)

feat(builder): ignore option to function the same as `.nuxtignore`
Fixed ignore option to function the same as .nuxtignore. 
Right now it does not function like the documentation shows. 

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [x] Bug fix (a non-breaking change which fixes an issue)
- [ ] New feature (a non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)


## Description
Added the ignore property from nuxt config options to the ignore class so it can then add the array of globs to the filter list for proper filtering. Currently, the way the files are resolved, the ignore option only works at a subfolder level forcing you to use the same ignore rules for each folder.

## Checklist:
<!--- Put an `x` in all the boxes that apply. -->
<!--- If your change requires a documentation PR, please link it appropriately -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly. (PR: #)
- [ ] I have added tests to cover my changes (if not applicable, please state why)
- [x] All new and existing tests are passing.




Patch:
diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js
index b27f8eed1..6b4c90fb0 100644
--- a/packages/builder/src/builder.js
+++ b/packages/builder/src/builder.js
@@ -82,7 +82,8 @@ export default class Builder {
     this.bundleBuilder = this.getBundleBuilder(bundleBuilder)
 
     this.ignore = new Ignore({
-      rootDir: this.options.srcDir
+      rootDir: this.options.srcDir,
+      ignoreArray: this.options.ignore
     })
   }
 
@@ -312,7 +313,6 @@ export default class Builder {
   async resolveFiles (dir, cwd = this.options.srcDir) {
     return this.ignore.filter(await glob(this.globPathWithExtensions(dir), {
       cwd,
-      ignore: this.options.ignore,
       follow: this.options.build.followSymlinks
     }))
   }
diff --git a/packages/builder/src/ignore.js b/packages/builder/src/ignore.js
index 984e7b4d8..d92936896 100644
--- a/packages/builder/src/ignore.js
+++ b/packages/builder/src/ignore.js
@@ -6,6 +6,7 @@ export default class Ignore {
   constructor (options) {
     this.rootDir = options.rootDir
     this.ignoreOptions = options.ignoreOptions
+    this.ignoreArray = options.ignoreArray
     this.addIgnoresRules()
   }
 
@@ -35,6 +36,12 @@ export default class Ignore {
     if (content) {
       this.ignore.add(content)
     }
+    if (this.ignoreArray && this.ignoreArray.length > 0) {
+      if (!this.ignore) {
+        this.ignore = ignore(this.ignoreOptions)
+      }
+      this.ignore.add(this.ignoreArray)
+    }
   }
 
   filter (paths) {


Test patch:
diff --git a/packages/builder/test/builder.generate.test.js b/packages/builder/test/builder.generate.test.js
index 0e64f0a62..88c42342c 100644
--- a/packages/builder/test/builder.generate.test.js
+++ b/packages/builder/test/builder.generate.test.js
@@ -102,7 +102,7 @@ describe('builder: builder generate', () => {
     expect(Glob).toBeCalledTimes(1)
     expect(Glob).toBeCalledWith(
       '/var/nuxt/dir/**/*.{vue,js}',
-      { cwd: '/var/nuxt/src', ignore: '/var/nuxt/ignore' }
+      { cwd: '/var/nuxt/src' }
     )
     expect(builder.ignore.filter).toBeCalledTimes(1)
     expect(builder.ignore.filter).toBeCalledWith('matched files')