-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBrocfile.js
executable file
·73 lines (69 loc) · 2.42 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
const funnel = require('broccoli-funnel');
const concat = require('broccoli-concat');
const concatMap = require('broccoli-sourcemap-concat');
const wrapFiles = require('broccoli-wrap');
const filterCoffeeScript = require('broccoli-coffee');
const uglifyJavaScript = require('broccoli-uglify-js')
const jshintTree = require('broccoli-jshint');
const mergeTrees = require('broccoli-merge-trees');
// const babel = require('broccoli-babel-transpiler');
const pkg = require('./package.json');
const bower_components = 'bower_components';
const src = 'src';
const vendor = funnel(bower_components,{
files: ['kurento-jsonrpc/js/kurento-jsonrpc.js','adapter.js/adapter.js','eventEmitter/EventEmitter.js','jquery/dist/jquery.js']
})
const indexHtml = funnel(src, {
files: ['index.html']
});
const coffeeFiles = filterCoffeeScript(src,{
bare: true
})
// const js = funnel(src, {
// files: ['index.js','lib/participant.js','lib/room.js','lib/stream.js']
// });
// const js = babel(src, {
// stage: 0,
// moduleIds: true,
// modules: 'amd',
// // Transforms /index.js files to use their containing directory name
// getModuleId: function (name) {
// name = 'kurento-room/' + name;
// return name.replace(/\/index$/, '');
// },
//
// // Fix relative imports inside /index's
// resolveModuleSource: function (source, filename) {
// var match = filename.match(/(.+)\/index\.\S+$/i);
//
// // is this an import inside an /index file?
// if (match) {
// var path = match[1];
// return source
// .replace(/^\.\//, path + '/')
// .replace(/^\.\.\//, '');
// } else {
// return source;
// }
// }
// });
// const appJs = mergeTrees([loaderFile,js]);
const jsHinted = jshintTree(coffeeFiles);
const main = concat(jsHinted, {
inputFiles: [
'**/*.js'
],
outputFile: '/kurento-room-without.js'
});
const wrapped = wrapFiles(main,{
wrapper: ["(function () {\n","if (typeof define === 'function' && define.amd) {\ndefine(function () {\nreturn KurentoRoom;\n});\n} else if (typeof module !== 'undefined' && module.exports) {\n module.exports = KurentoRoom; } else { this.KurentoRoom = KurentoRoom; }}.call(this));"]
});
const merged = mergeTrees([vendor,wrapped]);
const final = concatMap(merged, {
inputFiles: [
'**/*.js'
],
outputFile: '/kurento-room.js'
});
const uglifiedFinal = uglifyJavaScript(final);
module.exports = mergeTrees([uglifiedFinal, indexHtml]);