How to match every file but one in grunt concat?
Asked Answered
B

1

21

I'm using grunt to concatenate and minimize my js files, I use the following config for the concat part:

concat: {
  dist: {
    src: ['<banner:meta.banner>', 'js/*.js'],
    dest: 'js/script.js'
  }
}

It matches every file in my js folder but I need to ignore modernizr.js, is there a way to do this? I assume I'd need some pattern matching voodoo to do it but I'm not sure how.

Thanks in advance.

Benedikt answered 16/6, 2012 at 15:30 Comment(2)
Note that 'js/*.js' is not a regex, it is a path selector (or whatever they are called). A regex would have been js\/.*\.js (.* instead of *, and escaping the dot, at least). I'd look into other ways of excluding files, it may have additional configurations.Waxbill
You're right, it uses minimatch for file selection which converts expressions into JavaScript RegExp objects so it's not 100% regexBenedikt
T
33

Based on documentation I would try:

js/!(modernizr).js
(js/)!(modernizr).js
{js/}!(modernizr).js
js/!({modernizr}).js
(js/)!({modernizr}).js
{js/}!({modernizr}).js
js/!{modernizr}.js
(js/)!{modernizr}.js
{js/}!{modernizr}.js

If none of them is going to work, then probably you are of out luck...

Terra answered 16/6, 2012 at 18:54 Comment(2)
Thanks the first one worked fine, I was trying js/!modernizr.js before no wonder why it didn't work...Benedikt
@javiervd - In js/!modernizr.js you used negation just for letter m, that's why it didn't work...Debutant

© 2022 - 2024 — McMap. All rights reserved.