Skip to content

Commit 51b5bf5

Browse files
authored
feat(builder): ignore option to function the same as .nuxtignore (nuxt#7132)
1 parent f18e241 commit 51b5bf5

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/builder/src/builder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export default class Builder {
8282
this.bundleBuilder = this.getBundleBuilder(bundleBuilder)
8383

8484
this.ignore = new Ignore({
85-
rootDir: this.options.srcDir
85+
rootDir: this.options.srcDir,
86+
ignoreArray: this.options.ignore
8687
})
8788
}
8889

@@ -312,7 +313,6 @@ export default class Builder {
312313
async resolveFiles (dir, cwd = this.options.srcDir) {
313314
return this.ignore.filter(await glob(this.globPathWithExtensions(dir), {
314315
cwd,
315-
ignore: this.options.ignore,
316316
follow: this.options.build.followSymlinks
317317
}))
318318
}

packages/builder/src/ignore.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class Ignore {
66
constructor (options) {
77
this.rootDir = options.rootDir
88
this.ignoreOptions = options.ignoreOptions
9+
this.ignoreArray = options.ignoreArray
910
this.addIgnoresRules()
1011
}
1112

@@ -35,6 +36,12 @@ export default class Ignore {
3536
if (content) {
3637
this.ignore.add(content)
3738
}
39+
if (this.ignoreArray && this.ignoreArray.length > 0) {
40+
if (!this.ignore) {
41+
this.ignore = ignore(this.ignoreOptions)
42+
}
43+
this.ignore.add(this.ignoreArray)
44+
}
3845
}
3946

4047
filter (paths) {

packages/builder/test/builder.generate.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('builder: builder generate', () => {
102102
expect(Glob).toBeCalledTimes(1)
103103
expect(Glob).toBeCalledWith(
104104
'/var/nuxt/dir/**/*.{vue,js}',
105-
{ cwd: '/var/nuxt/src', ignore: '/var/nuxt/ignore' }
105+
{ cwd: '/var/nuxt/src' }
106106
)
107107
expect(builder.ignore.filter).toBeCalledTimes(1)
108108
expect(builder.ignore.filter).toBeCalledWith('matched files')

0 commit comments

Comments
 (0)