gulpfile.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. 'use strict';
  19. var gulp = require('gulp'),
  20. minifyHTML = require('gulp-minify-html'),
  21. minifyCss = require('gulp-minify-css'),
  22. Del = require('del'),
  23. Yargs = require('yargs'),
  24. RunSequence = require('run-sequence'),
  25. shell = require('gulp-shell');
  26. var argv = Yargs.argv;
  27. /**
  28. * Build Settings
  29. */
  30. var settings = {
  31. /*
  32. * Environment to build our application for
  33. *
  34. * If we have passed an environment via a
  35. * CLI option, then use that. If not attempt
  36. * to use the NODE_ENV. If not set, use production.
  37. */
  38. environment: !!argv.env ? argv.env : process.env.NODE_ENV || 'p',
  39. productionFolder: 'target/webapp-build',
  40. devFolder: 'src/main/webapp'
  41. };
  42. /**
  43. * Clean Task
  44. *
  45. * Clears the build folder from our
  46. * previous builds files.
  47. */
  48. gulp.task('clean', function(cb) {
  49. return Del([
  50. settings.productionFolder
  51. ], cb);
  52. });
  53. /**
  54. * minify JS Task
  55. *
  56. */
  57. gulp.task('minify-js', ['clean'], shell.task([
  58. 'node production/r.js -o production/build.js'
  59. ]));
  60. /**
  61. * minify CSS Task
  62. *
  63. */
  64. gulp.task('minify-css', ['minify-js'], function() {
  65. return gulp.src(settings.productionFolder+'/**/*.css')
  66. .pipe(minifyCss({
  67. compatibility: 'ie8'
  68. }))
  69. .pipe(gulp.dest(settings.productionFolder+'/'));
  70. });
  71. /**
  72. * minify HTML Task
  73. *
  74. */
  75. // gulp.task('minify-html', function() {
  76. // return gulp.src(settings.productionFolder+'/**/*.html')
  77. // .pipe(minifyHTML({
  78. // empty: true
  79. // }))
  80. // .pipe(gulp.dest(settings.productionFolder+'/'));
  81. // });
  82. /**
  83. * Build Task
  84. *
  85. */
  86. /*gulp.task('builProduction', ['minify-css'], shell.task([
  87. 'mvn clean compile package -Denv=' + settings.productionFolder
  88. ]));
  89. gulp.task('runProduction', ['builProduction'], shell.task([
  90. 'mvn exec:java -Denv=' + settings.productionFolder
  91. ]));
  92. gulp.task('runDev', ['buildDev'], shell.task([
  93. 'mvn exec:java -DwebAppDir=' + settings.devFolder
  94. ]));
  95. gulp.task('buildDev', shell.task([
  96. 'mvn clean compile package -DwebAppDir=' + settings.devFolder
  97. ]));*/
  98. /**
  99. * Default Task
  100. *
  101. * Run the above tasks in the correct order
  102. */
  103. gulp.task('default', function(cb) {
  104. /* if (settings.environment) {
  105. if (settings.environment == "p") {
  106. gulp.run(['runProduction']);
  107. }
  108. if (settings.environment == "d") {
  109. gulp.run(['runDev']);
  110. }
  111. }
  112. return gutil.log("All Done!");*/
  113. });