st782s | b54df0d | 2017-05-04 07:48:42 -0400 | [diff] [blame] | 1 | // Generated on 2015-09-27 using generator-angular-fullstack 2.1.1 |
| 2 | 'use strict'; |
| 3 | |
| 4 | module.exports = function (grunt) { |
| 5 | var localConfig; |
| 6 | try { |
| 7 | localConfig = require('./server/config/local.env'); |
| 8 | } catch (e) { |
| 9 | localConfig = {}; |
| 10 | } |
| 11 | |
| 12 | // Load grunt tasks automatically, when needed |
| 13 | require('jit-grunt')(grunt, { |
| 14 | express: 'grunt-express-server', |
| 15 | useminPrepare: 'grunt-usemin', |
| 16 | ngtemplates: 'grunt-angular-templates', |
| 17 | cdnify: 'grunt-google-cdn', |
| 18 | protractor: 'grunt-protractor-runner', |
| 19 | buildcontrol: 'grunt-build-control', |
| 20 | ngconstant: 'grunt-ng-constant' |
| 21 | }); |
| 22 | |
| 23 | // Time how long tasks take. Can help when optimizing build times |
| 24 | require('time-grunt')(grunt); |
| 25 | |
| 26 | grunt.loadNpmTasks('grunt-exec'); |
| 27 | |
| 28 | // Define the configuration for all the tasks |
| 29 | grunt.initConfig({ |
| 30 | |
| 31 | // Project settings |
| 32 | pkg: grunt.file.readJSON('package.json'), |
| 33 | yeoman: { |
| 34 | // configurable paths |
| 35 | client: require('./bower.json').appPath || 'client', |
| 36 | dist: 'dist' |
| 37 | }, |
| 38 | express: { |
| 39 | options: { |
| 40 | port: process.env.PORT || 9000 |
| 41 | }, |
| 42 | dev: { |
| 43 | options: { |
| 44 | script: 'server/app.js', |
| 45 | args:[ |
| 46 | grunt.option('min') ? '' : '--unmin', |
| 47 | grunt.option('server-conf') ? '--server-conf=' + grunt.option('server-conf') : '--server-conf=development' |
| 48 | ] |
| 49 | } |
| 50 | }, |
| 51 | dev_debug: { |
| 52 | options: { |
| 53 | script: 'server/app.js', |
| 54 | debug: true, |
| 55 | args:[ |
| 56 | grunt.option('min') ? '' : '--unmin', |
| 57 | grunt.option('server-conf') ? '--server-conf=' + grunt.option('server-conf') : '--server-conf=development' |
| 58 | ] |
| 59 | } |
| 60 | }, |
| 61 | mock: { |
| 62 | options: { |
| 63 | script: 'mock/server.js' |
| 64 | } |
| 65 | }, |
| 66 | prod: { |
| 67 | options: { |
| 68 | script: 'dist/server/app.js' |
| 69 | } |
| 70 | } |
| 71 | }, |
| 72 | open: { |
| 73 | server: { |
| 74 | url: 'http://localhost:<%= express.options.port %>/ecompportal/applicationsHome' |
| 75 | } |
| 76 | }, |
| 77 | watch: { |
| 78 | injectJS: { |
| 79 | files: [ |
| 80 | '<%= yeoman.client %>/{app,components}/**/*.js', |
| 81 | '!<%= yeoman.client %>/{app,components}/**/*.spec.js', |
| 82 | '!<%= yeoman.client %>/{app,components}/**/*.mock.js', |
| 83 | '!<%= yeoman.client %>/app/app.js'], |
| 84 | tasks: ['injector:scripts'] |
| 85 | }, |
| 86 | injectCss: { |
| 87 | files: [ |
| 88 | '<%= yeoman.client %>/{app,components}/**/*.css' |
| 89 | ], |
| 90 | tasks: ['injector:css'] |
| 91 | }, |
| 92 | mochaTest: { |
| 93 | files: ['server/**/*.spec.js'], |
| 94 | tasks: ['env:test', 'mochaTest'] |
| 95 | }, |
| 96 | jsTest: { |
| 97 | files: [ |
| 98 | '<%= yeoman.client %>/{app,components}/**/*.spec.js', |
| 99 | '<%= yeoman.client %>/{app,components}/**/*.mock.js' |
| 100 | ], |
| 101 | tasks: ['newer:jshint:all', 'karma'] |
| 102 | }, |
| 103 | injectLess: { |
| 104 | files: [ |
| 105 | '<%= yeoman.client %>/{app,components}/**/*.less'], |
| 106 | tasks: ['injector:less'] |
| 107 | }, |
| 108 | less: { |
| 109 | files: [ |
| 110 | '<%= yeoman.client %>/{app,components}/**/*.less'], |
| 111 | tasks: ['less', 'autoprefixer'] |
| 112 | }, |
| 113 | babel: { |
| 114 | files: [ |
| 115 | '<%= yeoman.client %>/{app,components}/**/*.js', |
| 116 | '!<%= yeoman.client %>/{app,components}/**/*.spec.js' |
| 117 | ], |
| 118 | tasks: ['babel'] |
| 119 | }, |
| 120 | gruntfile: { |
| 121 | files: ['Gruntfile.js'] |
| 122 | }, |
| 123 | livereload: { |
| 124 | files: [ |
| 125 | '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.css', |
| 126 | '{.tmp,<%= yeoman.client %>}/{app,components}/**/*.html', |
| 127 | |
| 128 | '.tmp/{app,components}/**/*.js', |
| 129 | |
| 130 | '!{.tmp,<%= yeoman.client %>}{app,components}/**/*.spec.js', |
| 131 | '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js', |
| 132 | '<%= yeoman.client %>/assets/images/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}' |
| 133 | ], |
| 134 | options: { |
| 135 | livereload: true |
| 136 | } |
| 137 | }, |
| 138 | express: { |
| 139 | files: [ |
| 140 | 'server/**/*.{js,json}' |
| 141 | ], |
| 142 | tasks: ['express:dev', 'wait'], |
| 143 | options: { |
| 144 | livereload: true, |
| 145 | spawn: false //Without this option specified express won't be reloaded |
| 146 | } |
| 147 | }, |
| 148 | mock:{ |
| 149 | files:[ |
| 150 | 'mock/**/*' |
| 151 | ], |
| 152 | tasks:['express:mock'], |
| 153 | options:{ |
| 154 | spawn: false |
| 155 | } |
| 156 | }, |
| 157 | clientConf: { |
| 158 | files: [ |
| 159 | 'client/configurations/*.json' |
| 160 | ], |
| 161 | tasks: ['ngconstant'] |
| 162 | } |
| 163 | }, |
| 164 | |
| 165 | // Make sure code styles are up to par and there are no obvious mistakes |
| 166 | jshint: { |
| 167 | options: { |
| 168 | jshintrc: '<%= yeoman.client %>/.jshintrc', |
| 169 | reporter: require('jshint-stylish') |
| 170 | }, |
| 171 | server: { |
| 172 | options: { |
| 173 | jshintrc: 'server/.jshintrc' |
| 174 | }, |
| 175 | src: [ |
| 176 | 'server/**/*.js', |
| 177 | '!server/**/*.spec.js' |
| 178 | ] |
| 179 | }, |
| 180 | serverTest: { |
| 181 | options: { |
| 182 | jshintrc: 'server/.jshintrc-spec' |
| 183 | }, |
| 184 | src: ['server/**/*.spec.js'] |
| 185 | }, |
| 186 | all: [ |
| 187 | '<%= yeoman.client %>/{app,components}/**/*.js', |
| 188 | '!<%= yeoman.client %>/{app,components}/**/*.spec.js', |
| 189 | '!<%= yeoman.client %>/{app,components}/**/*.mock.js' |
| 190 | ], |
| 191 | test: { |
| 192 | src: [ |
| 193 | '<%= yeoman.client %>/{app,components}/**/*.spec.js', |
| 194 | '<%= yeoman.client %>/{app,components}/**/*.mock.js' |
| 195 | ] |
| 196 | } |
| 197 | }, |
| 198 | |
| 199 | // Empties folders to start fresh |
| 200 | clean: { |
| 201 | dist: { |
| 202 | files: [{ |
| 203 | dot: true, |
| 204 | src: [ |
| 205 | '.tmp', |
| 206 | '<%= yeoman.dist %>/*', |
| 207 | '!<%= yeoman.dist %>/.git*', |
| 208 | '!<%= yeoman.dist %>/.openshift', |
| 209 | '!<%= yeoman.dist %>/Procfile' |
| 210 | ] |
| 211 | }] |
| 212 | }, |
| 213 | server: '.tmp' |
| 214 | }, |
| 215 | |
| 216 | // Add vendor prefixed styles |
| 217 | autoprefixer: { |
| 218 | options: { |
| 219 | browsers: ['last 1 version'] |
| 220 | }, |
| 221 | dist: { |
| 222 | files: [{ |
| 223 | expand: true, |
| 224 | cwd: '.tmp/', |
| 225 | src: '{,*/}*.css', |
| 226 | dest: '.tmp/' |
| 227 | }] |
| 228 | } |
| 229 | }, |
| 230 | |
| 231 | // // Debugging with node inspector |
| 232 | // 'node-inspector': { |
| 233 | // custom: { |
| 234 | // options: { |
| 235 | // 'web-host': 'localhost' |
| 236 | // } |
| 237 | // } |
| 238 | // }, |
| 239 | |
| 240 | // Use nodemon to run server in debug mode with an initial breakpoint |
| 241 | nodemon: { |
| 242 | debug: { |
| 243 | script: 'server/app.js', |
| 244 | options: { |
| 245 | nodeArgs: ['--debug-brk'], |
| 246 | env: { |
| 247 | PORT: process.env.PORT || 9000 |
| 248 | }, |
| 249 | callback: function (nodemon) { |
| 250 | nodemon.on('log', function (event) { |
| 251 | console.log(event.colour); |
| 252 | }); |
| 253 | |
| 254 | // opens browser on initial server start |
| 255 | nodemon.on('config:update', function () { |
| 256 | setTimeout(function () { |
| 257 | require('open')('http://localhost:8080/debug?port=5858'); |
| 258 | }, 500); |
| 259 | }); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | }, |
| 264 | |
| 265 | // Automatically inject Bower components into the app |
| 266 | wiredep: { |
| 267 | target: { |
| 268 | src: '<%= yeoman.client %>/index.html', |
| 269 | ignorePath: '<%= yeoman.client %>/', |
| 270 | exclude: [/bootstrap-sass-official/, /bootstrap.js/, '/json3/', '/es5-shim/', /bootstrap.css/, /font-awesome.css/] |
| 271 | } |
| 272 | }, |
| 273 | |
| 274 | // Renames files for browser caching purposes |
| 275 | rev: { |
| 276 | dist: { |
| 277 | files: { |
| 278 | src: [ |
| 279 | '<%= yeoman.dist %>/public/{,*/}*.js', |
| 280 | '<%= yeoman.dist %>/public/{,*/}*.css', |
| 281 | '<%= yeoman.dist %>/public/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', |
| 282 | '<%= yeoman.dist %>/public/assets/fonts/*', |
shentao999 | 96ed6fe | 2019-04-02 09:18:32 +0800 | [diff] [blame] | 283 | '<%= yeoman.dist %>/public/assets/i18n/{,*/}*.{json}', |
st782s | b54df0d | 2017-05-04 07:48:42 -0400 | [diff] [blame] | 284 | '!<%= yeoman.dist %>/public/assets/images/tmp/*' |
| 285 | ] |
| 286 | } |
| 287 | } |
| 288 | }, |
| 289 | |
| 290 | // Reads HTML for usemin blocks to enable smart builds that automatically |
| 291 | // concat, minify and revision files. Creates configurations in memory so |
| 292 | // additional tasks can operate on them |
| 293 | useminPrepare: { |
| 294 | html: ['<%= yeoman.client %>/index.html'], |
| 295 | options: { |
| 296 | dest: '<%= yeoman.dist %>/public' |
| 297 | } |
| 298 | }, |
| 299 | |
| 300 | // Performs rewrites based on rev and the useminPrepare configuration |
| 301 | usemin: { |
| 302 | html: ['<%= yeoman.dist %>/public/{,*/}*.html'], |
| 303 | css: ['<%= yeoman.dist %>/public/{,*/}*.css'], |
| 304 | js: ['<%= yeoman.dist %>/public/{,*/}*.js'], |
| 305 | options: { |
| 306 | assetsDirs: [ |
| 307 | '<%= yeoman.dist %>/public', |
| 308 | '<%= yeoman.dist %>/public/assets' |
| 309 | ], |
| 310 | // This is so we update image references in our ng-templates |
| 311 | patterns: { |
| 312 | js: [ |
| 313 | [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images'] |
| 314 | ] |
| 315 | } |
| 316 | } |
| 317 | }, |
| 318 | |
| 319 | // The following *-min tasks produce minified files in the dist folder |
| 320 | imagemin: { |
| 321 | dist: { |
| 322 | files: [{ |
| 323 | expand: true, |
| 324 | cwd: '<%= yeoman.client %>/assets/images', |
| 325 | src: '{,*/}*.{png,jpg,jpeg,gif}', |
| 326 | dest: '<%= yeoman.dist %>/public/assets/images' |
| 327 | }] |
| 328 | } |
| 329 | }, |
shentao999 | 96ed6fe | 2019-04-02 09:18:32 +0800 | [diff] [blame] | 330 | jsonmin: { |
| 331 | dist: { |
| 332 | files: [{ |
| 333 | expand: true, |
| 334 | cwd: '<%= yeoman.client %>/assets/i18n', |
| 335 | src: '{,*/}*.{json}', |
| 336 | dest: '<%= yeoman.dist %>/public/assets/i18n' |
| 337 | }] |
| 338 | } |
| 339 | }, |
st782s | b54df0d | 2017-05-04 07:48:42 -0400 | [diff] [blame] | 340 | |
| 341 | svgmin: { |
| 342 | dist: { |
| 343 | files: [{ |
| 344 | expand: true, |
| 345 | cwd: '<%= yeoman.client %>/assets/images', |
| 346 | src: '{,*/}*.svg', |
| 347 | dest: '<%= yeoman.dist %>/public/assets/images' |
| 348 | }] |
| 349 | } |
| 350 | }, |
| 351 | |
| 352 | // Allow the use of non-minsafe AngularJS files. Automatically makes it |
| 353 | // minsafe compatible so Uglify does not destroy the ng references |
| 354 | ngAnnotate: { |
| 355 | dist: { |
| 356 | files: [{ |
| 357 | expand: true, |
| 358 | cwd: '.tmp/concat', |
| 359 | src: '**/*.js', |
| 360 | dest: '.tmp/concat' |
| 361 | }] |
| 362 | } |
| 363 | }, |
| 364 | |
| 365 | // Package all the html partials into a single javascript payload |
| 366 | ngtemplates: { |
| 367 | app: { |
| 368 | options: { |
| 369 | prefix: '' |
| 370 | } |
| 371 | }, |
| 372 | options: { |
| 373 | // This should be the name of your apps angular module |
| 374 | module: 'ecompApp', |
| 375 | htmlmin: { |
| 376 | collapseBooleanAttributes: true, |
| 377 | collapseWhitespace: true, |
| 378 | removeAttributeQuotes: true, |
| 379 | removeEmptyAttributes: true, |
| 380 | removeRedundantAttributes: true, |
| 381 | removeScriptTypeAttributes: true, |
| 382 | removeStyleLinkTypeAttributes: true |
| 383 | }, |
| 384 | usemin: 'app/app.js' |
| 385 | }, |
| 386 | main: { |
| 387 | cwd: '<%= yeoman.client %>', |
| 388 | src: ['{app,components}/**/*.html'], |
| 389 | dest: '.tmp/templates.js' |
| 390 | }, |
| 391 | tmp: { |
| 392 | cwd: '.tmp', |
| 393 | src: ['{app,components}/**/*.html'], |
| 394 | dest: '.tmp/tmp-templates.js' |
| 395 | } |
| 396 | }, |
| 397 | |
| 398 | // Replace Google CDN references |
| 399 | cdnify: { |
| 400 | dist: { |
| 401 | html: ['<%= yeoman.dist %>/public/*.html'] |
| 402 | } |
| 403 | }, |
| 404 | |
| 405 | // Copies remaining files to places other tasks can use |
| 406 | copy: { |
| 407 | dist: { |
| 408 | files: [{ |
| 409 | expand: true, |
| 410 | dot: true, |
| 411 | cwd: '<%= yeoman.client %>', |
| 412 | dest: '<%= yeoman.dist %>/public', |
| 413 | src: [ |
| 414 | '*.{ico,png,txt}', |
| 415 | '.htaccess', |
| 416 | 'bower_components/**/*', |
| 417 | 'bower_components_external/**/*', |
| 418 | 'assets/images/**/*', |
shentao999 | 96ed6fe | 2019-04-02 09:18:32 +0800 | [diff] [blame] | 419 | 'assets/i18n/**/*', |
st782s | b54df0d | 2017-05-04 07:48:42 -0400 | [diff] [blame] | 420 | 'assets/fonts/**/*', |
| 421 | 'index.html' |
| 422 | ] |
| 423 | }, { |
| 424 | expand: true, |
| 425 | cwd: '.tmp/images', |
| 426 | dest: '<%= yeoman.dist %>/public/assets/images', |
| 427 | src: ['generated/*'] |
| 428 | }, { |
| 429 | expand: true, |
shentao999 | 96ed6fe | 2019-04-02 09:18:32 +0800 | [diff] [blame] | 430 | cwd: '.tmp/i18n', |
| 431 | dest: '<%= yeoman.dist %>/public/assets/i18n', |
| 432 | src: [ |
| 433 | 'CN.json', |
| 434 | 'EN.json' |
| 435 | ] |
| 436 | }, { |
| 437 | expand: true, |
st782s | b54df0d | 2017-05-04 07:48:42 -0400 | [diff] [blame] | 438 | dest: '<%= yeoman.dist %>', |
| 439 | src: [ |
| 440 | 'package.json', |
| 441 | 'server/**/*' |
| 442 | ] |
| 443 | }] |
| 444 | }, |
| 445 | styles: { |
| 446 | expand: true, |
| 447 | cwd: '<%= yeoman.client %>', |
| 448 | dest: '.tmp/', |
| 449 | src: ['{app,components}/**/*.css'] |
| 450 | } |
| 451 | }, |
| 452 | |
| 453 | buildcontrol: { |
| 454 | options: { |
| 455 | dir: 'dist', |
| 456 | commit: true, |
| 457 | push: true, |
| 458 | connectCommits: false, |
| 459 | message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%' |
| 460 | }, |
| 461 | heroku: { |
| 462 | options: { |
| 463 | remote: 'heroku', |
| 464 | branch: 'master' |
| 465 | } |
| 466 | }, |
| 467 | openshift: { |
| 468 | options: { |
| 469 | remote: 'openshift', |
| 470 | branch: 'master' |
| 471 | } |
| 472 | } |
| 473 | }, |
| 474 | |
| 475 | // Run some tasks in parallel to speed up the build process |
| 476 | concurrent: { |
| 477 | server: [ |
| 478 | 'babel', |
| 479 | 'less', |
| 480 | ], |
| 481 | test: [ |
| 482 | 'babel', |
| 483 | 'less', |
| 484 | ], |
| 485 | debug: { |
| 486 | tasks: [ |
| 487 | 'nodemon' |
| 488 | //'node-inspector' |
| 489 | ], |
| 490 | options: { |
| 491 | logConcurrentOutput: true |
| 492 | } |
| 493 | }, |
| 494 | dist: [ |
| 495 | 'babel', |
| 496 | 'less', |
| 497 | //'imagemin', |
| 498 | 'svgmin' |
| 499 | ] |
| 500 | }, |
| 501 | |
| 502 | // Test settings |
| 503 | karma: { |
| 504 | unit: { |
| 505 | configFile: 'karma.conf.js', |
| 506 | singleRun: true |
| 507 | } |
| 508 | }, |
| 509 | |
| 510 | mochaTest: { |
| 511 | options: { |
| 512 | reporter: 'spec' |
| 513 | }, |
| 514 | src: ['server/**/*.spec.js'] |
| 515 | }, |
| 516 | |
| 517 | protractor: { |
| 518 | options: { |
| 519 | configFile: 'protractor.conf.js' |
| 520 | }, |
| 521 | chrome: { |
| 522 | options: { |
| 523 | args: { |
| 524 | browser: 'chrome' |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | }, |
| 529 | |
| 530 | env: { |
| 531 | test: { |
| 532 | NODE_ENV: 'test' |
| 533 | }, |
| 534 | prod: { |
| 535 | NODE_ENV: 'production' |
| 536 | }, |
| 537 | all: localConfig |
| 538 | }, |
| 539 | |
| 540 | // Compiles ES6 to JavaScript using Babel |
| 541 | babel: { |
| 542 | options: { |
| 543 | sourceMap: true |
| 544 | }, |
| 545 | server: { |
| 546 | files: [{ |
| 547 | expand: true, |
| 548 | cwd: 'client', |
| 549 | src: [ |
| 550 | '{app,components}/**/*.js', |
| 551 | '!{app,components}/**/*.spec.js' |
| 552 | ], |
| 553 | dest: '.tmp' |
| 554 | }] |
| 555 | } |
| 556 | }, |
| 557 | |
| 558 | // Compiles Less to CSS |
| 559 | less: { |
| 560 | options: { |
| 561 | paths: [ |
| 562 | '<%= yeoman.client %>/bower_components', |
| 563 | '<%= yeoman.client %>/app', |
| 564 | '<%= yeoman.client %>/components' |
| 565 | ] |
| 566 | }, |
| 567 | server: { |
| 568 | files: { |
| 569 | '.tmp/app/app.css': '<%= yeoman.client %>/app/app.less' |
| 570 | } |
| 571 | }, |
| 572 | }, |
| 573 | |
| 574 | injector: { |
| 575 | options: {}, |
| 576 | // Inject application script files into index.html (doesn't include bower) |
| 577 | scripts: { |
| 578 | options: { |
| 579 | transform: function (filePath) { |
| 580 | filePath = filePath.replace('/client/', ''); |
| 581 | filePath = filePath.replace('/.tmp/', ''); |
| 582 | return '<script src="' + filePath + '"></script>'; |
| 583 | }, |
| 584 | starttag: '<!-- injector:js -->', |
| 585 | endtag: '<!-- endinjector -->' |
| 586 | }, |
| 587 | files: { |
| 588 | '<%= yeoman.client %>/index.html': [ |
| 589 | [ |
| 590 | |
| 591 | '.tmp/{app,components}/**/*.js', |
| 592 | |
| 593 | '!{.tmp,<%= yeoman.client %>}/app/app.js', |
| 594 | '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.spec.js', |
| 595 | '!{.tmp,<%= yeoman.client %>}/{app,components}/**/*.mock.js' |
| 596 | ] |
| 597 | ] |
| 598 | } |
| 599 | }, |
| 600 | |
| 601 | // Inject component less into app.less |
| 602 | less: { |
| 603 | options: { |
| 604 | transform: function (filePath) { |
| 605 | filePath = filePath.replace('/client/app/', ''); |
| 606 | filePath = filePath.replace('/client/components/', ''); |
| 607 | return '@import \'' + filePath + '\';'; |
| 608 | }, |
| 609 | starttag: '// injector', |
| 610 | endtag: '// endinjector' |
| 611 | }, |
| 612 | files: { |
| 613 | '<%= yeoman.client %>/app/app.less': [ |
| 614 | '<%= yeoman.client %>/{app,components}/**/*.less', |
| 615 | '!<%= yeoman.client %>/app/app.less' |
| 616 | ] |
| 617 | } |
| 618 | }, |
| 619 | |
| 620 | // Inject component css into index.html |
| 621 | css: { |
| 622 | options: { |
| 623 | transform: function (filePath) { |
| 624 | filePath = filePath.replace('/client/', ''); |
| 625 | filePath = filePath.replace('/.tmp/', ''); |
| 626 | return '<link rel="stylesheet" href="' + filePath + '">'; |
| 627 | }, |
| 628 | starttag: '<!-- injector:css -->', |
| 629 | endtag: '<!-- endinjector -->' |
| 630 | }, |
| 631 | files: { |
| 632 | '<%= yeoman.client %>/index.html': [ |
| 633 | '<%= yeoman.client %>/{app,components}/**/*.css' |
| 634 | ] |
| 635 | } |
| 636 | } |
| 637 | }, |
| 638 | |
| 639 | //Project configuration task |
| 640 | ngconstant: { |
| 641 | main: { |
| 642 | options: { |
| 643 | dest: 'client/app/configurations.js', |
| 644 | name: 'ecomp.conf' |
| 645 | }, |
| 646 | constants: function () { |
| 647 | if (!grunt.option('env')) { |
| 648 | grunt.fail.warn('env parameter missing, please use --env=<environment configuration>, ex: grunt serve --env=mock'); |
| 649 | } |
| 650 | |
| 651 | return { |
| 652 | conf: grunt.file.readJSON('client/configurations/' + grunt.option('env') + '.json') |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | }, |
| 657 | exec: { |
| 658 | delete: 'sshpass -p Aa123456 ssh root@remotehost rm -rf /var/lib/tomcat/webapps/ecompportal/public/', |
| 659 | copy: 'sshpass -p Aa123456 scp -r dist/public/ root@remotehost:/var/lib/tomcat/webapps/ecompportal/' |
| 660 | } |
| 661 | }); |
| 662 | |
| 663 | //Express server task |
| 664 | |
| 665 | // Used for delaying livereload until after server has restarted |
| 666 | grunt.registerTask('wait', function () { |
| 667 | grunt.log.ok('Waiting for server reload...'); |
| 668 | |
| 669 | var done = this.async(); |
| 670 | |
| 671 | setTimeout(function () { |
| 672 | grunt.log.writeln('Done waiting!'); |
| 673 | done(); |
| 674 | }, 1500); |
| 675 | }); |
| 676 | |
| 677 | grunt.registerTask('express-keepalive', 'Keep grunt running', function () { |
| 678 | this.async(); |
| 679 | }); |
| 680 | |
| 681 | grunt.registerTask('serve', function (target) { |
| 682 | |
| 683 | if (target === 'dist') { |
| 684 | return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'express:mock', 'wait', 'open', 'express-keepalive']); |
| 685 | } |
| 686 | |
| 687 | if (target === 'debug') { |
| 688 | return grunt.task.run([ |
| 689 | 'clean:server', |
| 690 | 'env:all', |
| 691 | 'injector:less', |
| 692 | 'concurrent:server', |
| 693 | 'express:mock', |
| 694 | 'injector', |
| 695 | 'wiredep', |
| 696 | 'autoprefixer', |
| 697 | 'concurrent:debug' |
| 698 | ]); |
| 699 | } |
| 700 | |
| 701 | var isDebug = grunt.option('dev_debug'); |
| 702 | |
| 703 | grunt.task.run([ |
| 704 | 'clean:server', |
| 705 | 'env:all', |
| 706 | 'ngconstant', |
| 707 | 'injector:less', |
| 708 | 'concurrent:server', |
| 709 | 'injector', |
| 710 | 'wiredep', |
| 711 | 'autoprefixer', |
| 712 | isDebug ? 'express:dev_debug' : 'express:dev', |
| 713 | 'express:mock', |
| 714 | 'wait', |
| 715 | 'open', |
| 716 | 'watch' |
| 717 | ]); |
| 718 | }); |
| 719 | |
| 720 | grunt.registerTask('server', function () { |
| 721 | grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); |
| 722 | grunt.task.run(['serve']); |
| 723 | }); |
| 724 | |
| 725 | grunt.registerTask('test', function (target) { |
| 726 | if (target === 'server') { |
| 727 | return grunt.task.run([ |
| 728 | 'env:all', |
| 729 | 'env:test', |
| 730 | 'mochaTest' |
| 731 | ]); |
| 732 | } |
| 733 | |
| 734 | else if (target === 'client') { |
| 735 | return grunt.task.run([ |
| 736 | 'clean:server', |
| 737 | 'env:all', |
| 738 | 'injector:less', |
| 739 | 'concurrent:test', |
| 740 | 'injector', |
| 741 | 'ngtemplates:main', |
| 742 | 'autoprefixer', |
| 743 | 'karma' |
| 744 | ]); |
| 745 | } |
| 746 | |
| 747 | else if (target === 'e2e') { |
| 748 | return grunt.task.run([ |
| 749 | 'clean:server', |
| 750 | 'env:all', |
| 751 | 'env:test', |
| 752 | 'injector:less', |
| 753 | 'concurrent:test', |
| 754 | 'injector', |
| 755 | 'wiredep', |
| 756 | 'autoprefixer', |
| 757 | 'express:dev', |
| 758 | 'protractor' |
| 759 | ]); |
| 760 | } |
| 761 | |
| 762 | else grunt.task.run([ |
| 763 | 'test:server', |
| 764 | 'test:client' |
| 765 | ]); |
| 766 | }); |
| 767 | |
| 768 | grunt.registerTask('build', [ |
| 769 | 'clean:dist', |
| 770 | 'injector:less', |
| 771 | 'ngconstant', |
| 772 | 'concurrent:dist', |
| 773 | 'injector', |
| 774 | 'wiredep', |
| 775 | 'useminPrepare', |
| 776 | 'autoprefixer', |
| 777 | 'ngtemplates', |
| 778 | 'concat', |
| 779 | 'ngAnnotate', |
| 780 | 'copy:dist', |
| 781 | //'cdnify', |
| 782 | 'cssmin', |
| 783 | 'uglify', |
| 784 | 'rev', |
| 785 | 'usemin' |
| 786 | ]); |
| 787 | |
| 788 | grunt.registerTask('default', [ |
| 789 | 'newer:jshint', |
| 790 | 'test', |
| 791 | 'build' |
| 792 | ]); |
| 793 | |
| 794 | grunt.registerTask('deploy', [ |
| 795 | 'build', |
| 796 | 'exec' |
| 797 | ]); |
| 798 | }; |