You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
7.2 KiB

  1. /*******************************
  2. Internal Task Collection
  3. *******************************/
  4. /* These tasks create packaged files from **dist** components
  5. Not intended to be called directly by a user because
  6. these do not build fresh from **src**
  7. */
  8. module.exports = function(gulp) {
  9. var
  10. // node dependencies
  11. fs = require('fs'),
  12. chmod = require('gulp-chmod'),
  13. concat = require('gulp-concat'),
  14. concatCSS = require('gulp-concat-css'),
  15. clone = require('gulp-clone'),
  16. gulpif = require('gulp-if'),
  17. header = require('gulp-header'),
  18. less = require('gulp-less'),
  19. minifyCSS = require('gulp-minify-css'),
  20. plumber = require('gulp-plumber'),
  21. print = require('gulp-print'),
  22. rename = require('gulp-rename'),
  23. replace = require('gulp-replace'),
  24. uglify = require('gulp-uglify'),
  25. // user config
  26. config = require('./../config/user'),
  27. docsConfig = require('./../config/docs'),
  28. // install config
  29. tasks = require('./../config/project/tasks'),
  30. release = require('./../config/project/release'),
  31. // shorthand
  32. globs = config.globs,
  33. assets = config.paths.assets,
  34. output = config.paths.output,
  35. source = config.paths.source,
  36. banner = tasks.banner,
  37. filenames = tasks.filenames,
  38. log = tasks.log,
  39. settings = tasks.settings
  40. ;
  41. /*--------------
  42. Packaged
  43. ---------------*/
  44. gulp.task('package uncompressed css', function() {
  45. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  46. .pipe(plumber())
  47. .pipe(replace(assets.uncompressed, assets.packaged))
  48. .pipe(concatCSS(filenames.concatenatedCSS))
  49. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  50. .pipe(gulp.dest(output.packaged))
  51. .pipe(print(log.created))
  52. ;
  53. });
  54. gulp.task('package compressed css', function() {
  55. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  56. .pipe(plumber())
  57. .pipe(replace(assets.uncompressed, assets.packaged))
  58. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  59. .pipe(minifyCSS(settings.minify))
  60. .pipe(header(banner, settings.header))
  61. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  62. .pipe(gulp.dest(output.packaged))
  63. .pipe(print(log.created))
  64. ;
  65. });
  66. gulp.task('package uncompressed js', function() {
  67. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.js')
  68. .pipe(plumber())
  69. .pipe(replace(assets.uncompressed, assets.packaged))
  70. .pipe(concat(filenames.concatenatedJS))
  71. .pipe(header(banner, settings.header))
  72. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  73. .pipe(gulp.dest(output.packaged))
  74. .pipe(print(log.created))
  75. ;
  76. });
  77. gulp.task('package compressed js', function() {
  78. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.js')
  79. .pipe(plumber())
  80. .pipe(replace(assets.uncompressed, assets.packaged))
  81. .pipe(concat(filenames.concatenatedMinifiedJS))
  82. .pipe(uglify(settings.uglify))
  83. .pipe(header(banner, settings.header))
  84. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  85. .pipe(gulp.dest(output.packaged))
  86. .pipe(print(log.created))
  87. ;
  88. });
  89. /*--------------
  90. RTL
  91. ---------------*/
  92. gulp.task('package uncompressed rtl css', function () {
  93. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  94. .pipe(replace(assets.uncompressed, assets.packaged))
  95. .pipe(concatCSS(filenames.concatenatedRTLCSS))
  96. .pipe(gulp.dest(output.packaged))
  97. .pipe(print(log.created))
  98. ;
  99. });
  100. gulp.task('package compressed rtl css', function () {
  101. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  102. .pipe(replace(assets.uncompressed, assets.packaged))
  103. .pipe(concatCSS(filenames.concatenatedMinifiedRTLCSS))
  104. .pipe(minifyCSS(settings.minify))
  105. .pipe(header(banner, settings.header))
  106. .pipe(gulp.dest(output.packaged))
  107. .pipe(print(log.created))
  108. ;
  109. });
  110. gulp.task('package uncompressed docs css', function() {
  111. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  112. .pipe(plumber())
  113. .pipe(replace(assets.uncompressed, assets.packaged))
  114. .pipe(concatCSS(filenames.concatenatedCSS))
  115. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  116. .pipe(gulp.dest(output.packaged))
  117. .pipe(print(log.created))
  118. ;
  119. });
  120. gulp.task('package compressed docs css', function() {
  121. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  122. .pipe(plumber())
  123. .pipe(replace(assets.uncompressed, assets.packaged))
  124. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  125. .pipe(minifyCSS(settings.minify))
  126. .pipe(header(banner, settings.header))
  127. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  128. .pipe(gulp.dest(output.packaged))
  129. .pipe(print(log.created))
  130. ;
  131. });
  132. /*--------------
  133. Docs
  134. ---------------*/
  135. output = docsConfig.paths.output;
  136. source = docsConfig.paths.source;
  137. gulp.task('package uncompressed docs css', function() {
  138. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  139. .pipe(plumber())
  140. .pipe(replace(assets.uncompressed, assets.packaged))
  141. .pipe(concatCSS(filenames.concatenatedCSS))
  142. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  143. .pipe(gulp.dest(output.packaged))
  144. .pipe(print(log.created))
  145. ;
  146. });
  147. gulp.task('package compressed docs css', function() {
  148. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  149. .pipe(plumber())
  150. .pipe(replace(assets.uncompressed, assets.packaged))
  151. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  152. .pipe(minifyCSS(settings.minify))
  153. .pipe(header(banner, settings.header))
  154. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  155. .pipe(gulp.dest(output.packaged))
  156. .pipe(print(log.created))
  157. ;
  158. });
  159. gulp.task('package uncompressed docs js', function() {
  160. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.js')
  161. .pipe(plumber())
  162. .pipe(replace(assets.uncompressed, assets.packaged))
  163. .pipe(concat(filenames.concatenatedJS))
  164. .pipe(header(banner, settings.header))
  165. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  166. .pipe(gulp.dest(output.packaged))
  167. .pipe(print(log.created))
  168. ;
  169. });
  170. gulp.task('package compressed docs js', function() {
  171. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.js')
  172. .pipe(plumber())
  173. .pipe(replace(assets.uncompressed, assets.packaged))
  174. .pipe(concat(filenames.concatenatedMinifiedJS))
  175. .pipe(uglify(settings.uglify))
  176. .pipe(header(banner, settings.header))
  177. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  178. .pipe(gulp.dest(output.packaged))
  179. .pipe(print(log.created))
  180. ;
  181. });
  182. };