Gruntfile.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. var path = require('path');
  2. module.exports = function(grunt) {
  3. require('load-grunt-tasks')(grunt);
  4. /**
  5. * Resolve external project resource as file path
  6. */
  7. function resolvePath(project, file) {
  8. return path.join(path.dirname(require.resolve(project)), file);
  9. }
  10. grunt.initConfig({
  11. browserify: {
  12. options: {
  13. browserifyOptions: {
  14. debug: true
  15. },
  16. transform: [
  17. [ 'stringify', {
  18. extensions: [ '.bpmn' ]
  19. } ]
  20. ],
  21. plugin: [
  22. 'esmify'
  23. ]
  24. },
  25. watch: {
  26. options: {
  27. watch: true
  28. },
  29. files: {
  30. 'dist/index.js': [ 'app/**/*.js' ]
  31. }
  32. },
  33. app: {
  34. files: {
  35. 'dist/index.js': [ 'app/**/*.js' ]
  36. }
  37. }
  38. },
  39. copy: {
  40. diagram_js: {
  41. files: [
  42. {
  43. src: resolvePath('diagram-js', 'assets/diagram-js.css'),
  44. dest: 'dist/css/diagram-js.css'
  45. }
  46. ]
  47. },
  48. bpmn_js: {
  49. files: [
  50. {
  51. expand: true,
  52. cwd: resolvePath('bpmn-js', 'dist/assets'),
  53. src: ['**/*.*', '!**/*.js'],
  54. dest: 'dist/vendor'
  55. }
  56. ]
  57. },
  58. app: {
  59. files: [
  60. {
  61. expand: true,
  62. cwd: 'app/',
  63. src: ['**/*.*', '!**/*.js'],
  64. dest: 'dist'
  65. }
  66. ]
  67. }
  68. },
  69. less: {
  70. options: {
  71. dumpLineNumbers: 'comments',
  72. paths: [
  73. 'node_modules'
  74. ]
  75. },
  76. styles: {
  77. files: {
  78. 'dist/css/app.css': 'styles/app.less'
  79. }
  80. }
  81. },
  82. watch: {
  83. options: {
  84. livereload: true
  85. },
  86. samples: {
  87. files: [ 'app/**/*.*' ],
  88. tasks: [ 'copy:app' ]
  89. },
  90. less: {
  91. files: [
  92. 'styles/**/*.less',
  93. 'node_modules/bpmn-js-properties-panel/styles/**/*.less'
  94. ],
  95. tasks: [
  96. 'less'
  97. ]
  98. },
  99. },
  100. connect: {
  101. livereload: {
  102. options: {
  103. port: 9013,
  104. livereload: true,
  105. hostname: 'localhost',
  106. open: true,
  107. base: [
  108. 'dist'
  109. ]
  110. }
  111. }
  112. }
  113. });
  114. // tasks
  115. grunt.registerTask('build', [ 'copy', 'less', 'browserify:app' ]);
  116. grunt.registerTask('auto-build', [
  117. 'copy',
  118. 'less',
  119. 'browserify:watch',
  120. 'connect:livereload',
  121. 'watch'
  122. ]);
  123. grunt.registerTask('default', [ 'build' ]);
  124. };