forked from thoov/mock-socket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Brocfile.js
80 lines (70 loc) · 2.33 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
76
77
78
79
80
var funnel = require('broccoli-funnel');
var jsHint = require('broccoli-jshint');
var concat = require('broccoli-concat');
var uglifyJavaScript = require('broccoli-uglify-js');
var mergeTrees = require('broccoli-merge-trees');
var moduleLookupHash = require('./helpers/module-lookup');
var fastBrowserify = require('broccoli-fast-browserify');
var babelTransform = require('broccoli-babel-transpiler');
var pathNormalization = require('./helpers/module-path-normalization');
var thirdPartyLibaries = mergeTrees([
funnel('node_modules/URIjs/src', {
include: [
'punycode.js',
'IPv6.js',
'SecondLevelDomains.js',
'URI.js'
],
destDir: '/'}),
funnel('node_modules/qunitjs/qunit', { include: ['qunit.js'], destDir: '/'})
]);
var testFiles = mergeTrees([
// Load all of the test files (ie: all files ending with -test.js)
funnel('tests', { include: ['*-test.js', 'test-loader.js'], destDir: '/'}),
funnel('tests/bug-reports', { include: ['*-test.js'], destDir: '/bug-reports'}),
funnel('tests/unit', { include: ['*-test.js'], destDir: '/unit'}),
funnel('tests/functional', { include: ['*-test.js'], destDir: '/functional'}),
]);
var completeTree = mergeTrees([
thirdPartyLibaries,
funnel('src', {destDir: '/src'}),
testFiles
]);
var es5Tree = babelTransform(completeTree, {
blacklist: ['useStrict'],
resolveModuleSource: function(source, filepath) {
if(moduleLookupHash[source]) {
return pathNormalization(filepath) + moduleLookupHash[source].filename;
}
return source;
}
});
var browserifiedTree = fastBrowserify(es5Tree, {
bundles: {
'mock-socket.js': { entryPoints: ['**/main.js'] },
'tests.js': { entryPoints: ['test-loader.js'] }
}
});
var minifiedTree = uglifyJavaScript(funnel(browserifiedTree, {
include: ['mock-socket.js'],
getDestinationPath: function() {
return 'mock-socket.min.js';
}
}));
var jshintTree = concat(jsHint(
mergeTrees([
funnel('src', {destDir: '/src'}),
funnel('./', {include: ['.jshintrc']})
])
), {
inputFiles: [
'**/*.jshint.js'
],
outputFile: '/jshint-loader.js'
});
module.exports = mergeTrees([
browserifiedTree,
minifiedTree,
funnel('helpers', { include: ['playground.html'], getDestinationPath: function() { return 'index.html'; } }),
jshintTree
]);