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.

130 lines
3.2 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 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/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/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 script files
  64. // TODO: do not package moment.js with vis.js.
  65. var b = browserify();
  66. b.add(VIS_TMP);
  67. b.bundle({
  68. standalone: 'vis'
  69. }, function (err, code) {
  70. // add header and footer
  71. var lib = read('./src/header.js') + code;
  72. // write bundled file
  73. write(VIS, lib);
  74. console.log('created ' + VIS);
  75. // remove temporary file
  76. fs.unlinkSync(VIS_TMP);
  77. // update version number and stuff in the javascript files
  78. replacePlaceholders(VIS);
  79. complete();
  80. });
  81. });
  82. /**
  83. * minify the visualization library vis.js
  84. */
  85. desc('Minify the visualization library vis.js');
  86. task('minify', function () {
  87. // minify javascript
  88. minify({
  89. src: VIS,
  90. dest: VIS_MIN,
  91. header: read('./src/header.js')
  92. });
  93. // update version number and stuff in the javascript files
  94. replacePlaceholders(VIS_MIN);
  95. console.log('created ' + VIS_MIN);
  96. });
  97. /**
  98. * replace version, date, and name placeholders in the provided file
  99. * @param {String} filename
  100. */
  101. var replacePlaceholders = function (filename) {
  102. replace({
  103. replacements: [
  104. {pattern: '@@name', replacement: 'vis.js'},
  105. {pattern: '@@date', replacement: today()},
  106. {pattern: '@@version', replacement: version()}
  107. ],
  108. src: filename
  109. });
  110. };