I have a project where I have many javascript files, some are global and work on all pages and I have two group of files that are only meant for the home page and the rest are ok for the other pages. This is my config file, it's probably very wrong, it's my first time with brunch:
exports.config =
# See docs at http://brunch.readthedocs.org/en/latest/config.html.
# Application build path. Default is public
#buildPath: 'webapp'
paths:
public: 'webapp/assets'
compass: './config.rb'
watched: ['app', 'experiences', 'main', 'home', 'node_modules']
files:
javascripts:
defaultExtension: 'js'
joinTo:
'javascripts/app.js': /^main/
'javascripts/experiences.js': /^experiences/
'javascripts/home.js': /^home/
order:
before: [
'jquery.js',
'custom.modernizr.js',
'jquery.simplemodal.js',
'foundation.js',
'fastclick.js',
'retina.min.js'
]
stylesheets:
defaultExtension: 'styl'
joinTo:
'stylesheets/app.css': /^app\/styles\/app/
'stylesheets/ie.css': /^app\/styles\/ie/
templates:
defaultExtension: 'hbs'
joinTo: 'javascripts/templates.js'
minify: yes
modules:
wrapper: false
So in my app folders there's all the files that show in the before array but the order is not working at all and jquery is not before the others, and I'm getting js errors. I'm not sure if brunch is made to work this way but I can't have all the scripts in just one file like I said, because the home scripts are incompatible with the rest (I haven't made them, I just need to integrate the already working project with brunch)
Have you tried being explicit about your file paths in the before array? E.g.
files:
javascripts:
defaultExtension: 'js'
joinTo:
'javascripts/app.js': /^main/
'javascripts/experiences.js': /^experiences/
'javascripts/home.js': /^home/
order:
before: [
'app/main/jquery.js',
'app/main/custom.modernizr.js',
'app/experiences/jquery.simplemodal.js',
'app/home/foundation.js',
'app/home/fastclick.js',
'app/home/retina.min.js'
]
Maybe this might clear up things for Brunch. Perhaps take a look at this trick too. It will allow you to customize your structure better and simultaneously keep it unambiguous for Brunch in the config file.