blob: d9d90d81d213b4a7046091ac84b84606e377acd1 [file] [log] [blame]
Eran (ev672n), Voskb9708a72018-08-07 14:15:05 +03001// Generated on 2016-05-30 using generator-angular 0.15.1
2'use strict';
3
4// # Globbing for performance reasons we're only matching one level down:
5// 'test/spec/{,*/}*.js' use this if you want to recursively match all
6// subfolders: 'test/spec/**/*.js'
7
8module.exports = function (grunt) {
9
10 // Time how long tasks take. Can help when optimizing build times
11 require('time-grunt')(grunt);
12
13 // Automatically load required Grunt tasks
14 require('jit-grunt')(grunt, {
15 useminPrepare: 'grunt-usemin',
16 ngtemplates: 'grunt-angular-templates',
17 cdnify: 'grunt-google-cdn',
18 ngconstant: 'grunt-ng-constant',
19 mkdir: 'grunt-mkdir',
20 preprocess: 'grunt-preprocess'
21 });
22
23 // Configurable paths for the application
24 var appConfig = {
25 app: require('./bower.json').appPath || 'app',
26 tmp: {
27 exploded: '.tmp',
28 imploded: '.tmp_imploded'
29 },
30 dist: {
31 exploded: 'dist/exploded',
32 imploded: 'dist/imploded',
33 war: 'dist/war'
34 }
35 };
36
37 // Define the configuration for all the tasks
38 grunt.initConfig({
39
40 // Project settings
41 yeoman: appConfig,
42
43 // Watches files for changes and runs tasks based on the changed files
44 watch: {
45 bower: {
46 files: ['bower.json'],
47 tasks: ['wiredep']
48 },
49 js: {
50 files: ['<%= yeoman.app %>/main/{,*/}*.js'],
51 tasks: [
52 'newer:jshint:all', 'newer:jscs:all'
53 ],
54 options: {
55 livereload: '<%= connect.options.livereload %>'
56 }
57 },
58 injector: {
59 files: [
60 'app/styles/*.less', 'app/core/**/*.less', 'app/main/**/*.less'
61 ],
62 taskd: ['injector']
63 },
64 less: {
65 files: ['app/**/*.less'],
66 tasks: ['less:development'],
67 options: {
68 nospawn: true
69 }
70 },
71 styles: {
72 files: ['<%= yeoman.app %>/main/{,*/}*.css'],
73 tasks: ['newer:copy:styles', 'postcss']
74 },
75 gruntfile: {
76 files: ['Gruntfile.js']
77 },
78 options: {
79 livereload: true
80 },
81 livereload: {
82 options: {
83 livereload: '<%= connect.options.livereload %>'
84 },
85 files: ['<%= yeoman.app %>/{,*/}*.html', '<%= yeoman.app %>/styles/app.css', '<%= yeoman.app %>/styles/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}']
86 }
87 },
88
89 /*
90 concat: {
91 options: {
92 stripBanners: true
93 },
94 exploded: {
95 dest: '<%= yeoman.tmp.exploded %>'
96 }
97 },
98 */
99
100 ngconstant: {
101 // Options for all targets
102 options: {
103 space: ' ',
104 wrap: '"use strict";\n\n {\%= __ngModule %}',
105 name: 'dcaeApp.env'
106 },
107 // Environment targets
108 dev: {
109 options: {
110 dest: '<%= yeoman.app %>/app.env.js'
111 },
112 constants: {
113 ENV: {
114 name: 'development',
115 apiBase: 'http://localhost:8080/',
116 host: 'http://localhost:8446/',
117 catalogImport: '/comp-fe/',
118 catalogPrefix: 'http://localhost:8446',
119 cookieUser: 'ym903w',
120 ruleEditorUrl: 'http://localhost:4200'
121 }
122 }
123 },
124 exploded: {
125 options: {
126 dest: '<%= yeoman.app %>/app.env.js'
127 },
128 constants: {
129 ENV: {
130 name: 'production',
131 apiBase: '/dcae/dcaeProxyOld/',
132 host: '/dcae/dcaeProxyOld/',
133 catalogImport: '/dcae/comp-fe/',
134 catalogPrefix: '/dcae/dcaeProxyOld/',
135 cookieUser: 'le056g',
136 ruleEditorUrl: '/rule_engine'
137 }
138 }
139 }
140 },
141
142 // The actual grunt server settings
143 connect: {
144 options: {
145 port: 9000,
146 // Change this to '0.0.0.0' to access the server from outside.
147 hostname: 'localhost',
148 livereload: true
149 },
150 livereload: {
151 options: {
152 open: true,
153 middleware: function (connect) {
154 return [
155 //connect.static('.tmp'),
156 connect().use('/bower_components', connect.static('./bower_components')),
157 connect().use('/app/styles', connect.static('./app/styles')),
158 connect.static(appConfig.app)
159 ];
160 }
161 }
162 },
163 test: {
164 options: {
165 port: 9001,
166 middleware: function (connect) {
167 return [
168 connect.static('<%= yeoman.tmp.exploded %>'),
169 connect.static('test'),
170 connect().use('/bower_components', connect.static('./bower_components')),
171 connect.static(appConfig.app)
172 ];
173 }
174 }
175 },
176 exploded: {
177 options: {
178 open: true,
179 base: '<%= yeoman.dist.exploded %>'
180 }
181 }
182 },
183
184 // app.less contains all the less from all places, convert it to CSS
185 less: {
186 development: {
187 files: {
188 'app/styles/app.css': 'app/styles/app.less'
189 }
190 },
191 production: {
192 files: {
193 '<%= yeoman.tmp.exploded %>/styles/app.css': 'app/styles/app.less'
194 }
195 }
196 },
197
198 injector: {
199 options: {},
200 // Inject all project less into app.less
201 less: {
202 options: {
203 transform: function (filePath) {
204 filePath = filePath.replace('/app/styles/', '../styles/');
205 filePath = filePath.replace('/app/main/', '../main/');
206 filePath = filePath.replace('/app/core/', '../core/');
207 return '@import \'' + filePath + '\';';
208 },
209 starttag: '// injector:less',
210 endtag: '// endinjector:less'
211 },
212 files: {
213 'app/styles/app.less': ['app/styles/*.less', 'app/core/**/*.less', 'app/main/**/*.less', '!app/styles/app.less']
214 }
215 }
216 },
217
218 // Make sure there are no obvious mistakes
219 jshint: {
220 options: {
221 jshintrc: '.jshintrc',
222 reporter: require('jshint-stylish')
223 },
224 all: {
225 src: ['Gruntfile.js', '<%= yeoman.app %>/main/{,*/}*.js']
226 },
227 test: {
228 options: {
229 jshintrc: 'test/.jshintrc'
230 },
231 src: ['test/spec/{,*/}*.js']
232 }
233 },
234
235 // Make sure code styles are up to par
236 jscs: {
237 options: {
238 config: '.jscsrc',
239 verbose: true
240 },
241 all: {
242 src: ['Gruntfile.js', '<%= yeoman.app %>/main/{,*/}*.js']
243 },
244 test: {
245 src: ['test/spec/{,*/}*.js']
246 }
247 },
248
249 // Empties folders to start fresh
250 clean: {
251 exploded: {
252 files: [
253 {
254 dot: true,
255 src: ['<%= yeoman.tmp.exploded %>', '<%= yeoman.dist.exploded %>/{,*/}*', '!<%= yeoman.dist.exploded %>/.git{,*/}*']
256 }
257 ]
258 },
259 imploded: {
260 files: [
261 {
262 dot: true,
263 src: ['<%= yeoman.dist.imploded %>']
264 }
265 ]
266 },
267 html: {
268 files: [
269 {
270 dot: true,
271 src: ['<%= yeoman.dist.exploded %>/index.html']
272 }
273 ]
274 },
275 server: '<%= yeoman.tmp.exploded %>'
276 },
277
278 // Add vendor prefixed styles
279 postcss: {
280 options: {
281 processors: [require('autoprefixer-core')({browsers: ['last 1 version']})]
282 },
283 server: {
284 options: {
285 map: true
286 },
287 files: [
288 {
289 expand: true,
290 cwd: '<%= yeoman.tmp.exploded %>/styles/',
291 src: '{,*/}*.css',
292 dest: '<%= yeoman.tmp.exploded %>/styles/'
293 }
294 ]
295 },
296 exploded: {
297 files: [
298 {
299 expand: true,
300 cwd: '<%= yeoman.tmp.exploded %>/styles/',
301 src: '{,*/}*.css',
302 dest: '<%= yeoman.tmp.exploded %>/styles/'
303 }
304 ]
305 }
306 },
307
308 // Automatically inject Bower components into the app
309 wiredep: {
310 app: {
311 src: ['<%= yeoman.app %>/index.html'],
312 ignorePath: /\.\.\//
313 }
314 },
315
316 // Renames files for browser caching purposes
317 filerev: {
318 exploded: {
319 src: ['<%= yeoman.dist.exploded %>/scripts/{,*/}*.js', '<%= yeoman.dist.exploded %>/styles/{,*/}*.css', '<%= yeoman.dist.exploded %>/styles/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', '<%= yeoman.dist.exploded %>/styles/fonts/*']
320 }
321 },
322
323 // Reads HTML for usemin blocks to enable smart builds that automatically
324 // concat, minify and revision files. Creates configurations in memory so
325 // additional tasks can operate on them
326 useminPrepare: {
327 html: '<%= yeoman.app %>/index.html',
328 options: {
329 dest: '<%= yeoman.dist.exploded %>',
330 flow: {
331 html: {
332 steps: {
333 js: [
334 'concat', 'uglifyjs'
335 ],
336 css: ['cssmin']
337 },
338 post: {}
339 }
340 }
341 }
342 },
343
344 // Performs rewrites based on filerev and the useminPrepare configuration
345 usemin: {
346 html: ['<%= yeoman.dist.exploded %>/{,*/}*.html'],
347 css: ['<%= yeoman.dist.exploded %>/styles/{,*/}*.css'],
348 js: ['<%= yeoman.dist.exploded %>/scripts/{,*/}*.js'],
349 options: {
350 assetsDirs: [
351 '<%= yeoman.dist.exploded %>', '<%= yeoman.dist.exploded %>/styles/images', '<%= yeoman.dist.exploded %>/styles'
352 ],
353 patterns: {
354 js: [
355 [/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']
356 ]
357 }
358 }
359 },
360
361 imagemin: {
362 exploded: {
363 files: [
364 {
365 expand: true,
366 cwd: '<%= yeoman.app %>/styles/images',
367 src: '**/*.{png,jpg,jpeg,gif}',
368 dest: '<%= yeoman.dist.exploded %>/styles/images'
369 }
370 ]
371 }
372 },
373
374 svgmin: {
375 exploded: {
376 files: [
377 {
378 expand: true,
379 cwd: '<%= yeoman.app %>/styles/images',
380 src: '{,*/}*.svg',
381 dest: '<%= yeoman.dist.exploded %>/styles/images'
382 }
383 ]
384 }
385 },
386
387 htmlmin: {
388 exploded: {
389 options: {
390 collapseWhitespace: true,
391 conservativeCollapse: true,
392 collapseBooleanAttributes: true,
393 removeCommentsFromCDATA: true
394 },
395 files: [
396 {
397 expand: true,
398 cwd: '<%= yeoman.dist.exploded %>',
399 src: ['*.html'],
400 dest: '<%= yeoman.dist.exploded %>'
401 }
402 ]
403 }
404 },
405
406 ngtemplates: {
407 exploded: {
408 options: {
409 module: 'dcaeApp',
410 htmlmin: '<%= htmlmin.exploded.options %>',
411 usemin: 'scripts/scripts.js'
412 },
413 cwd: '<%= yeoman.app %>',
414 src: [
415 'main/**/*.html', 'core/**/*.html', 'comp-fe/**/*.html'
416 ],
417 dest: '<%= yeoman.tmp.exploded %>/templateCache.js'
418 }
419 },
420
421 // ng-annotate tries to make the code safe for minification automatically by
422 // using the Angular long form for dependency injection.
423 ngAnnotate: {
424 exploded: {
425 files: [
426 {
427 expand: true,
428 cwd: '<%= yeoman.tmp.exploded %>/concat/scripts',
429 src: '*.js',
430 dest: '<%= yeoman.tmp.exploded %>/concat/scripts'
431 }
432 ]
433 }
434 },
435
436 // Replace Google CDN references
437 cdnify: {
438 exploded: {
439 html: ['<%= yeoman.dist.exploded %>/*.html']
440 }
441 },
442
443 // Copies remaining files to places other tasks can use
444 copy: {
445 exploded: {
446 files: [
447 {
448 expand: true,
449 dot: true,
450 cwd: '<%= yeoman.app %>',
451 dest: '<%= yeoman.dist.exploded %>',
452 src: ['*.{ico,png,txt}', '*.html', 'styles/images/{,*/}*.{webp}', 'styles/fonts/{,*/}*.*']
453 }, {
454 expand: true,
455 cwd: '<%= yeoman.tmp.exploded %>/images',
456 dest: '<%= yeoman.dist.exploded %>/styles/images',
457 src: ['generated/*']
458 }, {
459 expand: true,
460 cwd: 'bower_components/bootstrap/dist',
461 src: 'fonts/*',
462 dest: '<%= yeoman.dist.exploded %>'
463 }, {
464 expand: true,
465 cwd: '<%= yeoman.app %>',
466 src: ['WEB-INF/*'],
467 dest: '<%= yeoman.dist.exploded %>/'
468 }, {
469 expand: true,
470 cwd: '<%= yeoman.app %>',
471 src: ['dcae.xml'],
472 dest: '<%= yeoman.dist.exploded %>/'
473 }
474 ]
475 },
476 styles: {
477 expand: true,
478 cwd: '<%= yeoman.app %>/styles',
479 dest: '<%= yeoman.tmp.exploded %>/styles/',
480 src: '{,*/}*.css'
481 },
482 tmpImploded: {
483 expand: true,
484 cwd: '<%= yeoman.dist.exploded %>',
485 dest: '<%= yeoman.tmp.imploded %>',
486 src: '**/*'
487 },
488 copyComposition: {
489 expand: true,
490 cwd: '<%= yeoman.app %>',
491 dest: '<%= yeoman.dist.imploded %>',
492 src: 'comp-fe/**/*'
493 },
494 copyProject: {
495 expand: true,
496 cwd: '<%= yeoman.app %>',
497 dest: '<%= yeoman.dist.exploded %>',
498 src: ['**/*']
499 },
500 copyIndex: {
501 expand: true,
502 cwd: '<%= yeoman.app %>/prodHtml',
503 dest: '<%= yeoman.dist.exploded %>',
504 src: ['**/*']
505 },
506 copyComposition2: {
507 expand: true,
508 cwd: '<%= yeoman.app %>',
509 dest: '<%= yeoman.dist.exploded %>',
510 src: 'comp-fe/**/*'
511 },
512 imploded: {
513 expand: true,
514 cwd: '<%= yeoman.dist.exploded %>',
515 dest: '<%= yeoman.dist.imploded %>',
516 src: ['dcae.xml', 'WEB-INF/**']
517 }
518 },
519
520 // Run some tasks in parallel to speed up the build process
521 concurrent: {
522 server: [
523 'less:development', 'copy:styles'
524 ],
525 test: ['copy:styles'],
526 exploded: [
527 'less:production', 'copy:styles', 'imagemin', 'svgmin'
528 ],
529 style: ['less:production']
530 },
531
532 mkdir: {
533 all: {
534 options: {
535 create: ['<%= yeoman.dist.exploded %>/WEB-INF']
536 }
537 },
538 dist: {
539 options: {
540 create: ['<%= yeoman.dist %>']
541 }
542 },
543 imploded: {
544 options: {
545 create: ['<%= yeoman.dist.imploded %>', '<%= yeoman.tmp.imploded %>']
546 }
547 }
548 },
549
550 preprocess: {
551 options: {
552 inline: true,
553 context: {
554 DEBUG: false
555 }
556 },
557 /*html : {
558 src : [
559 '<%= yeoman.dist %>/index.html',
560 '<%= yeoman.dist %>/views/*.html'
561 ]
562 },*/
563 js: {
564 src: '<%= yeoman.tmp.exploded %>/concat/scripts/*.js'
565 }
566 }
567
568 });
569
570 grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
571 if (target === 'dist') {
572 return grunt
573 .task
574 .run(['build', 'connect:exploded:keepalive']);
575 }
576
577 grunt
578 .task
579 .run([
580 'clean:server', // Delete .tmp folder
581 'ngconstant:dev', // Configure constants
582 'wiredep', // Automatically inject Bower components into the app
583 'injector', // Inject the less files to app.less
584 'concurrent:server', // Run some tasks in parallel to speed up the build process, need to see what the task run.
585 'postcss:server', // Add vendor prefixed styles
586 'connect:livereload',
587 'watch'
588 ]);
589 });
590
591 grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
592 grunt
593 .log
594 .warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
595 grunt
596 .task
597 .run(['serve:' + target]);
598 });
599
600 grunt.registerTask('test', ['clean:server', 'wiredep', 'concurrent:test', 'postcss', 'connect:test']);
601
602 grunt.registerTask('build', [
603 'clean:exploded',
604 'ngconstant:exploded',
605 'wiredep',
606 'injector',
607 'concurrent:exploded',
608 'useminPrepare',
609 'postcss',
610 'ngtemplates',
611 'concat',
612 'preprocess:js',
613 'ngAnnotate',
614 //'mkdir',
615 'copy:exploded',
616 //'cdnify',
617 'cssmin',
618 'uglify',
619 'mkdir:imploded',
620 'clean:imploded',
621 'copy:tmpImploded', // Copy the files before changing their names
622 'copy:imploded', // Copy the WEB-INF folder and dcae.xml
623 'filerev', // This will change the name of the files for caching.
624 'usemin',
625 'copy:copyComposition'
626 //'htmlmin'
627 ]);
628
629 grunt.registerTask('build2', [
630 'clean:exploded',
631 'ngconstant:exploded',
632 'wiredep',
633 'injector',
634 'concurrent:style',
635 'postcss',
636 // 'useminPrepare', 'postcss', 'ngtemplates', 'concat', 'preprocess:js',
637 // 'ngAnnotate', 'mkdir',
638 'copy:copyProject',
639 'clean:html',
640 'copy:copyIndex'
641 ]);
642
643 grunt.registerTask('default', ['newer:jshint', 'newer:jscs', 'test', 'build']);
644};