3

I understand how brunch handles javascript files, combining them into individual output files:

  files:
    javascripts:
      joinTo:
        'javascripts/app.js': /^app/
        'javascripts/vendor.js': /^vendor/
        'test/javascripts/test.js': /^test(\/|\\)(?!vendor)/
        'test/javascripts/test-vendor.js': /^test(\/|\\)(?=vendor)/

the 2nd line, for example, takes all the javascript files in the /vendor/ folder and makes the vendor.js

The Regex (/^vendor/) specifies a folder path correct? Any way to have the regex apply to the file names as well? For example if there was a jquery.js and a jquery.min.js, I just want the jquery.js file included. Is this possible?

Bryce Fischer
  • 5,336
  • 9
  • 30
  • 36

3 Answers3

5

You can use functions to test against paths. With them stuff should be simple:

joinTo:
  'javascripts/vendor.js': (path) ->
    /^vendor/.test(path) and not /\.min\.js$/.test(path)
Paul Miller
  • 1,960
  • 1
  • 13
  • 15
2

You can give the paths to be ignored. The regex should match complete path for files, filenames included.

paths:
  public: '../deploy'
  ignored: 'vendor/styles/bootstrap'
  test: 'spec'

ignored key: string, regExp, function or array of them. Will check against files that would be ignored by brunch compilator.

But as Amberlamps suggested you can give regex to exclude *.min.js files in the files .

PS: Never tested it but in the docs somewhere it is mentioned /_spec\.\w+$/ matches for user_spec.js.

user568109
  • 47,225
  • 17
  • 99
  • 123
1

I have never used brunch before, but if it is using RegExp to find specific paths you can exclude *.min.js files using:

/^((?!vendor\/.*\.min\.js).)*$/

I used following answer as reference: Regular expression to match string not containing a word?

Community
  • 1
  • 1
Amberlamps
  • 39,180
  • 5
  • 43
  • 53
  • Thanks. I think the regex only applies to paths though, not filenames. I may be wrong however.... Likely wrong in fact.. :-) – Bryce Fischer Mar 27 '13 at 13:22
  • Yeah, if it is just applied to paths, this answer is getting you nowhere. Let me know how it worked out. – Amberlamps Mar 27 '13 at 13:24