-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.coffee
108 lines (85 loc) · 2.8 KB
/
config.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
glob = require 'glob'
Lazy = require 'lazy.js'
# The `bower.json` config file
bower = require './bower'
# Acceptable template extensions
TEMPLATE_EXTENSIONS = bower.curve.templates.extensions
# See docs at https://github.com/brunch/brunch/blob/stable/docs/config.md
exports.config =
conventions:
assets: /^app\/assets\//
paths:
watched: ['app', 'components']
# We use AngularJS' own DI mechanism
modules:
definition: false
wrapper: false
server:
port: 8888
files:
javascripts:
joinTo:
# Non-spec and compoennt scripts are application code
'app.js': /^(app|components)\/(?!.+\.spec\.)/
# Specs are compiled into another file by themselves
'_dev/spec.js': /^(app|components)\/(?!.+\.spec\.)/
# Vendor code
'vendor.js': /^(bower_components)\/(?!.+\.spec\.)/
order:
after: bower.curve.javascripts.order.after or []
before: (glob.sync(
# Templates first as they have no dependency whatsoever
"+(app|components)/**/*.+(#{TEMPLATE_EXTENSIONS})"
)).concat(
# Essential libraries to load before the rest
bower.curve.javascripts.order.before or []
).concat(glob.sync(
# Library files first
'bower_components/**/*.js'
)).concat(glob.sync(
# Module entry points
'components/**/index.*'
)).concat(glob.sync(
# Modules
'components/**/*'
)).concat(glob.sync(
# Main entry point
'app/index.*'
)).concat(glob.sync(
# Individual entry points
'app/**/index.*'
)).concat(glob.sync(
# Project-specific shared libraries
'app/common/**/*'
))
stylesheets:
joinTo:
'app.css': /^(app|components)/
'vendor.css': /^(bower_components)/
templates:
joinTo:
'app.js': /^(app|components)/
plugins:
coffeescript:
# Auto-wrap in self-calling function
bare: false
appcache:
ignore: /_dev/
# Process the JavaScript `joinTo` object to separate out user-defined `splitTo`
# files (defined in `bower.json`)
joinTo = exports.config.files.javascripts.joinTo
splitTo = bower.curve.javascripts.splitTo
# All the `splitTo`s, flattened
splitTos = Lazy(splitTo).values().flatten()
# Each `joinTo` should exclude those in `splitTo`
Lazy(joinTo).each (pattern, path) ->
# Substitute the pattern with a function that matches the pattern as well as
# excludes `splitTo` paths
joinTo[path] = (file) ->
# It must match the original pattern but not in `splitTo`s
file.match(pattern)? and not splitTos.contains(file)
# Also construct new `joinTo` based on `splitTo`
Lazy(splitTo).each (paths, name) ->
paths = Lazy paths
joinTo["#{name}.js"] = (file) ->
paths.contains file