-
Notifications
You must be signed in to change notification settings - Fork 8
/
Brocfile.js
52 lines (44 loc) · 1.44 KB
/
Brocfile.js
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
var rimraf = require('rimraf'),
mergeTrees = require('broccoli-merge-trees'),
Funnel = require('broccoli-funnel'),
compileSass = require('broccoli-sass'),
babelTranspiler = require('broccoli-babel-transpiler'),
fastBrowserify = require('broccoli-fast-browserify'),
uglifyJavaScript = require('broccoli-uglify-js'),
gzipFiles = require('broccoli-gzip'),
env = require('broccoli-env').getEnv();
// copy index.html
var staticFiles = new Funnel('src', {
files: ['index.html']
});
// convert SCSS into CSS
var cssFiles = compileSass(['src'], 'styles/app.scss', 'styles/app.css');
// exclude tests from build
var jsFiles = new Funnel('src', {
exclude: [new RegExp(/__tests__/)],
include: [new RegExp(/\.js$/)]
});
// transpile ES6/7 into ES5
jsFiles = babelTranspiler(jsFiles, {
stage: 0,
sourceMaps: 'inline', // add sourcemaps for ES6 debugging
plugins: ['typecheck'] // add Flow types checking!
});
// transpile for the browser
jsFiles = fastBrowserify(jsFiles, {
debug: env !== 'production', // add sourcemaps if not for production
bundles: {
'index.js': {
entryPoints: ['index.js']
}
}
});
if (env === 'production') {
jsFiles = uglifyJavaScript(jsFiles);
jsFiles = gzipFiles(jsFiles, {
extensions: ['js', 'css'],
keepUncompressed: true
});
}
rimraf.sync('./dist');
module.exports = mergeTrees([staticFiles, cssFiles, jsFiles], {overwrite: true});