forked from tildeio/rsvp.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Brocfile.js
75 lines (66 loc) · 1.87 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* jshint node:true, undef:true, unused:true */
var AMDFormatter = require('es6-module-transpiler-amd-formatter');
var closureCompiler = require('broccoli-closure-compiler');
var compileModules = require('broccoli-compile-modules');
var mergeTrees = require('broccoli-merge-trees');
var moveFile = require('broccoli-file-mover');
var es3Recast = require('broccoli-es3-safe-recast');
var concat = require('broccoli-concat');
var replace = require('broccoli-string-replace');
var calculateVersion = require('git-repo-version');
var path = require('path');
var trees = [];
var env = process.env.EMBER_ENV || 'development';
var bundle = compileModules('lib', {
inputFiles: ['rsvp.umd.js'],
output: '/rsvp.js',
formatter: 'bundle',
});
trees.push(bundle);
trees.push(compileModules('lib', {
inputFiles: ['**/*.js'],
output: '/amd/',
formatter: new AMDFormatter()
}));
if (process.env.EMBER_ENV === 'production') {
trees.push(closureCompiler(moveFile(bundle, {
srcFile: 'rsvp.js',
destFile: 'rsvp.min.js'
}), {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
externs: ['node'],
}));
}
var distTree = mergeTrees(trees.concat('config'));
var distTrees = [];
distTrees.push(concat(distTree, {
inputFiles: [
'versionTemplate.txt',
'rsvp.js'
],
outputFile: '/rsvp.js'
}));
if (process.env.EMBER_ENV === 'production') {
distTrees.push(concat(distTree, {
inputFiles: [
'versionTemplate.txt',
'rsvp.min.js'
],
outputFile: '/rsvp.min.js'
}));
}
if (env !== 'development') {
distTrees = distTrees.map(es3Recast);
}
distTree = mergeTrees(distTrees);
var distTree = replace(distTree, {
files: [
'rsvp.js',
'rsvp.min.js'
],
pattern: {
match: /VERSION_PLACEHOLDER_STRING/g,
replacement: calculateVersion(10)
}
});
module.exports = distTree;