[CLAMP-1] Initial ONAP CLAMP seed code commit
[clamp.git] / src / main / resources / META-INF / resources / designer / modeler / Gruntfile.js
1 module.exports = function(grunt) {
2
3   require('load-grunt-tasks')(grunt);
4
5   var path = require('path');
6
7   /**
8    * Resolve external project resource as file path
9    */
10   function resolvePath(project, file) {
11     return path.join(path.dirname(require.resolve(project)), file);
12   }
13
14   // project configuration
15   grunt.initConfig({
16     pkg: grunt.file.readJSON('package.json'),
17
18     config: {
19       sources: 'app',
20       dist: 'dist'
21     },
22
23     jshint: {
24       src: [
25         ['<%=config.sources %>']
26       ],
27       options: {
28         jshintrc: true
29       }
30     },
31
32     browserify: {
33       options: {
34         browserifyOptions: {
35           // make sure we do not include browser shims unnecessarily
36           builtins: false,
37           insertGlobalVars: {
38             process: function () {
39                 return 'undefined';
40             },
41             Buffer: function () {
42                 return 'undefined';
43             }
44           }
45         },
46         transform: [ 'brfs' ]
47       },
48       watch: {
49         options: {
50           watch: true
51         },
52         files: {
53           '<%= config.dist %>/index.js': [ '<%= config.sources %>/**/*.js' ]
54         }
55       },
56       app: {
57         files: {
58           '<%= config.dist %>/index.js': [ '<%= config.sources %>/**/*.js' ]
59         }
60       }
61     },
62     copy: {
63       diagram_js: {
64         files: [
65           {
66             src: resolvePath('diagram-js', 'assets/diagram-js.css'),
67             dest: '<%= config.dist %>/css/diagram-js.css'
68           }
69         ]
70       },
71       bpmn_js: {
72         files: [
73           {
74             expand: true,
75             cwd: resolvePath('bpmn-js', 'assets'),
76             src: ['**/*.*', '!**/*.js'],
77             dest: '<%= config.dist %>/vendor'
78           }
79         ]
80       },
81       app: {
82         files: [
83           {
84             expand: true,
85             cwd: '<%= config.sources %>/',
86             src: ['**/*.*', '!**/*.js'],
87             dest: '<%= config.dist %>'
88           }
89         ]
90       }
91     },
92     watch: {
93       samples: {
94         files: [ '<%= config.sources %>/**/*.*' ],
95         tasks: [ 'copy:app' ]
96       },
97     },
98     connect: {
99       options: {
100         port: 9013,
101         livereload: 9014,
102         hostname: 'localhost'
103       },
104       livereload: {
105         options: {
106           open: true,
107           base: [
108             '<%= config.dist %>'
109           ]
110         }
111       }
112     }
113   });
114
115   // tasks
116
117   grunt.registerTask('build', [ 'copy', 'browserify:app' ]);
118
119   grunt.registerTask('auto-build', [
120     'copy',
121     'browserify:watch',
122     'connect:livereload',
123     'watch'
124   ]);
125
126   grunt.registerTask('default', [ 'jshint', 'build' ]);
127 };