简体   繁体   中英

Exclude file in Brunch regular expression

I want to exclude a file mapdata.coffee inside the view folder in joinTo config of Brunch.

What I tried is

'javascripts/app.js':/^app(\/|\\)(?!(tests|store-test|views\/mapdata.coffee))/

Where am I missing?

Seems like it should work, unless you're on a Windows system using backslashes as the path separator. In which case

/^app[\\\/](?!(tests|store-test|views[\\\/]mapdata.coffee))/

ought to work.

In a node REPL:

> /^app(\/|\\)(?!(tests|store-test|views\/mapdata.coffee))/.test('app/views/mapdata.coffee')
false
> /^app(\/|\\)(?!(tests|store-test|views\/mapdata.coffee))/.test('app\\views\\mapdata.coffee')
true
> /^app[\\\/](?!(tests|store-test|views[\\\/]mapdata.coffee))/.test('app\\views\\mapdata.coffee')
false
> /^app[\\\/](?!(tests|store-test|views[\\\/]mapdata.coffee))/.test('app\\views\\foo.coffee')
true

You can also define your joinTo s with things other than regexes. Take a look at the anymatch documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM