vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.1 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. /**
  2. * Jake build script
  3. */
  4. var jake = require('jake'),
  5. browserify = require('browserify'),
  6. path = require('path'),
  7. fs = require('fs');
  8. require('jake-utils');
  9. // constants
  10. var VIS = './vis.js';
  11. var VIS_TMP = './vis.js.tmp';
  12. var VIS_MIN = './vis.min.js';
  13. /**
  14. * default task
  15. */
  16. desc('Execute all tasks: build all libraries');
  17. task('default', ['build', 'minify'], function () {
  18. console.log('done');
  19. });
  20. /**
  21. * build the visualization library vis.js
  22. */
  23. desc('Build the visualization library vis.js');
  24. task('build', {async: true}, function () {
  25. // concatenate and stringify the css files
  26. var result = concat({
  27. src: [
  28. './src/component/css/panel.css',
  29. './src/component/css/item.css',
  30. './src/component/css/timeaxis.css'
  31. ],
  32. header: '/* vis.js stylesheet */',
  33. separator: '\n'
  34. });
  35. var cssText = JSON.stringify(result.code);
  36. // concatenate the script files
  37. concat({
  38. dest: VIS_TMP,
  39. src: [
  40. './src/module/imports.js',
  41. './src/util.js',
  42. './src/events.js',
  43. './src/timestep.js',
  44. './src/dataset.js',
  45. './src/stack.js',
  46. './src/range.js',
  47. './src/controller.js',
  48. './src/component/component.js',
  49. './src/component/panel.js',
  50. './src/component/rootpanel.js',
  51. './src/component/timeaxis.js',
  52. './src/component/itemset.js',
  53. './src/component/item/*.js',
  54. './src/visualization/timeline.js',
  55. './src/module/exports.js'
  56. ],
  57. separator: '\n',
  58. // Note: we insert the css as a string in the javascript code here
  59. // the css will be injected on load of the javascript library
  60. footer: '// inject css\n' +
  61. 'util.loadCss(' + cssText + ');\n'
  62. });
  63. // bundle the concatenated script and dependencies into one file
  64. var b = browserify();
  65. b.add(VIS_TMP);
  66. b.bundle({
  67. standalone: 'vis'
  68. }, function (err, code) {
  69. // add header and footer
  70. var lib = read('./src/header.js') + code;
  71. // write bundled file
  72. write(VIS, lib);
  73. console.log('created ' + VIS);
  74. // remove temporary file
  75. fs.unlinkSync(VIS_TMP);
  76. // update version number and stuff in the javascript files
  77. replacePlaceholders(VIS);
  78. complete();
  79. });
  80. });
  81. /**
  82. * minify the visualization library vis.js
  83. */
  84. desc('Minify the visualization library vis.js');
  85. task('minify', function () {
  86. // minify javascript
  87. minify({
  88. src: VIS,
  89. dest: VIS_MIN,
  90. header: read('./src/header.js')
  91. });
  92. // update version number and stuff in the javascript files
  93. replacePlaceholders(VIS_MIN);
  94. console.log('created ' + VIS_MIN);
  95. });
  96. /**
  97. * replace version, date, and name placeholders in the provided file
  98. * @param {String} filename
  99. */
  100. var replacePlaceholders = function (filename) {
  101. replace({
  102. replacements: [
  103. {pattern: '@@date', replacement: today()},
  104. {pattern: '@@version', replacement: version()}
  105. ],
  106. src: filename
  107. });
  108. };