This repository has been archived by the owner on May 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
brunch-config.coffee
115 lines (102 loc) · 2.74 KB
/
brunch-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
109
110
111
112
113
114
115
_ = require 'lodash'
bourbon = require 'node-bourbon'
fs = require 'fs'
fse = require 'fs-extra'
glob = require 'glob'
global.DEBUG = '-p' not in global.process.argv
global._COPIED = no
copy_map = [
['node_modules/@blueprintjs/core/resources', 'public/resources']
]
PROD = process.env.STAGING? or process.env.PRODUCTION?
STATIC_ROOT =
if PROD
"//#{process.env.AWS_BUCKET_NAME}.s3.amazonaws.com"
else '/static'
# [@prashnts] This bit here is used to generate the watched folders
MODULE_PATH = '**/frontend/**/@(index|main).@(coffee|cjsx|jsx|js|styl|sass)'
watched = _
.chain(glob.sync MODULE_PATH)
.map (filename) ->
[__, dirname] = /^(.+)\/(index|main).\w+$/.exec filename
dirname
.uniq()
.value()
bundles = do ->
bndls =
js: 'js/vendors.js': /^node_modules/
css: 'css/vendors.css': /^node_modules/
for path in watched
cpath = path.replace /\/?frontend/, ''
app = if /^frontend/.test path then 'common' else cpath.replace /\//, '_'
bndls.js["js/#{app}.js"] = new RegExp "^#{path}\/[\\-_\\d\\w]+\\.\\w+$"
bndls.css["css/#{app}.css"] = new RegExp "^#{path}\/[\\-_\\d\\w]+\\.\\w+$"
bndls
console.log "==> #{unless PROD then 'Dev' else 'Production'} build"
console.log " --> Static root set to: #{STATIC_ROOT}"
console.log "==> Discovered #{watched.length} components"
for k, v of bundles.js
console.log " --> #{/js\/(.+)\.js/.exec(k)[1]}"
module.exports = config:
paths:
watched: watched
conventions:
ignored: [
/tests\//
/^frontend\/.+\.styl$/
]
plugins:
autoReload:
enabled: yes
postcss:
processors: [
require('autoprefixer')(['last 8 versions'])
]
sass:
options:
mode: 'ruby'
debug: 'debug'
allowCache: true
includePaths: [
'./node_modules/@blueprintjs/core/dist/'
'./node_modules/tachyons-sass/'
bourbon.includePaths...
]
babel:
presets: ['es2015', 'react', 'stage-2']
ignore: [
/^(node_modules)/
]
pattern: /\.jsx?$/
npm:
enabled: yes
styles:
'@blueprintjs/core': [
'dist/blueprint.css'
]
globals:
jQuery: 'jquery'
$: 'jquery'
modules:
nameCleaner: (path) ->
path
.replace /\.cjsx/, ''
.replace /\.coffee/, ''
.replace /\.js/, ''
.replace /\.jsx/, ''
.replace /\.sass/, ''
.replace /frontend\//, ''
.replace /\/index/, ''
files:
javascripts:
joinTo: bundles.js
stylesheets:
joinTo: bundles.css
hooks:
preCompile: (end) ->
unless global._COPIED
for [src, dest] in copy_map
fse.copySync src, dest
console.log 'Copied', src, 'to', dest
global._COPIED = yes
end()