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.

95 lines
2.3 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. require('jake-utils');
  8. // constants
  9. var VIS = './vis.js';
  10. var VIS_MIN = './vis.min.js';
  11. /**
  12. * default task
  13. */
  14. desc('Execute all tasks: build all libraries');
  15. task('default', ['build', 'minify'], function () {
  16. console.log('done');
  17. });
  18. /**
  19. * build the visualization library vis.js
  20. */
  21. desc('Build the visualization library vis.js');
  22. task('build', {async: true}, function () {
  23. // concatenate and stringify css files
  24. var result = concat({
  25. src: [
  26. './src/component/css/panel.css',
  27. './src/component/css/item.css',
  28. './src/component/css/timeaxis.css'
  29. ],
  30. header: '/* vis.js stylesheet */',
  31. separator: '\n'
  32. });
  33. var cssText = JSON.stringify(result.code);
  34. // bundle the script files
  35. // TODO: do not package moment.js with vis.js.
  36. var b = browserify();
  37. b.add('./src/vis.js');
  38. b.bundle({
  39. standalone: 'vis'
  40. }, function (err, code) {
  41. // add header and footer
  42. var lib =
  43. read('./src/header.js') +
  44. code +
  45. read('./src/module.js') +
  46. '\nloadCss(' + cssText + ');\n'; // inline css
  47. // write bundled file
  48. write(VIS, lib);
  49. console.log('created ' + VIS);
  50. // update version number and stuff in the javascript files
  51. replacePlaceholders(VIS);
  52. complete();
  53. });
  54. });
  55. /**
  56. * minify the visualization library vis.js
  57. */
  58. desc('Minify the visualization library vis.js');
  59. task('minify', function () {
  60. // minify javascript
  61. minify({
  62. src: VIS,
  63. dest: VIS_MIN,
  64. header: read('./src/header.js')
  65. });
  66. // update version number and stuff in the javascript files
  67. replacePlaceholders(VIS_MIN);
  68. console.log('created ' + VIS_MIN);
  69. });
  70. /**
  71. * replace version, date, and name placeholders in the provided file
  72. * @param {String} filename
  73. */
  74. var replacePlaceholders = function (filename) {
  75. replace({
  76. replacements: [
  77. {pattern: '@@name', replacement: 'vis.js'},
  78. {pattern: '@@date', replacement: today()},
  79. {pattern: '@@version', replacement: version()}
  80. ],
  81. src: filename
  82. });
  83. };