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. banner = tasks.banner,
  36. filenames = tasks.filenames,
  37. log = tasks.log,
  38. settings = tasks.settings
  39. ;
  40. /*--------------
  41. Packaged
  42. ---------------*/
  43. gulp.task('package uncompressed css', function() {
  44. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  45. .pipe(plumber())
  46. .pipe(replace(assets.uncompressed, assets.packaged))
  47. .pipe(concatCSS(filenames.concatenatedCSS))
  48. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  49. .pipe(gulp.dest(output.packaged))
  50. .pipe(print(log.created))
  51. ;
  52. });
  53. gulp.task('package compressed css', function() {
  54. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  55. .pipe(plumber())
  56. .pipe(replace(assets.uncompressed, assets.packaged))
  57. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  58. .pipe(minifyCSS(settings.minify))
  59. .pipe(header(banner, settings.header))
  60. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  61. .pipe(gulp.dest(output.packaged))
  62. .pipe(print(log.created))
  63. ;
  64. });
  65. gulp.task('package uncompressed js', function() {
  66. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.js')
  67. .pipe(plumber())
  68. .pipe(replace(assets.uncompressed, assets.packaged))
  69. .pipe(concat(filenames.concatenatedJS))
  70. .pipe(header(banner, settings.header))
  71. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  72. .pipe(gulp.dest(output.packaged))
  73. .pipe(print(log.created))
  74. ;
  75. });
  76. gulp.task('package compressed js', function() {
  77. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.js')
  78. .pipe(plumber())
  79. .pipe(replace(assets.uncompressed, assets.packaged))
  80. .pipe(concat(filenames.concatenatedMinifiedJS))
  81. .pipe(uglify(settings.uglify))
  82. .pipe(header(banner, settings.header))
  83. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  84. .pipe(gulp.dest(output.packaged))
  85. .pipe(print(log.created))
  86. ;
  87. });
  88. /*--------------
  89. RTL
  90. ---------------*/
  91. gulp.task('package uncompressed rtl css', function () {
  92. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  93. .pipe(replace(assets.uncompressed, assets.packaged))
  94. .pipe(concatCSS(filenames.concatenatedRTLCSS))
  95. .pipe(gulp.dest(output.packaged))
  96. .pipe(print(log.created))
  97. ;
  98. });
  99. gulp.task('package compressed rtl css', function () {
  100. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  101. .pipe(replace(assets.uncompressed, assets.packaged))
  102. .pipe(concatCSS(filenames.concatenatedMinifiedRTLCSS))
  103. .pipe(minifyCSS(settings.minify))
  104. .pipe(header(banner, settings.header))
  105. .pipe(gulp.dest(output.packaged))
  106. .pipe(print(log.created))
  107. ;
  108. });
  109. gulp.task('package uncompressed docs css', function() {
  110. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  111. .pipe(plumber())
  112. .pipe(replace(assets.uncompressed, assets.packaged))
  113. .pipe(concatCSS(filenames.concatenatedCSS))
  114. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  115. .pipe(gulp.dest(output.packaged))
  116. .pipe(print(log.created))
  117. ;
  118. });
  119. gulp.task('package compressed docs css', function() {
  120. return gulp.src(output.uncompressed + '**/' + globs.components + globs.ignored + '.css')
  121. .pipe(plumber())
  122. .pipe(replace(assets.uncompressed, assets.packaged))
  123. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  124. .pipe(minifyCSS(settings.minify))
  125. .pipe(header(banner, settings.header))
  126. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  127. .pipe(gulp.dest(output.packaged))
  128. .pipe(print(log.created))
  129. ;
  130. });
  131. /*--------------
  132. Docs
  133. ---------------*/
  134. var
  135. docsOutput = docsConfig.paths.output
  136. ;
  137. gulp.task('package uncompressed docs css', function() {
  138. return gulp.src(docsOutput.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(docsOutput.packaged))
  144. .pipe(print(log.created))
  145. ;
  146. });
  147. gulp.task('package compressed docs css', function() {
  148. return gulp.src(docsOutput.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(docsOutput.packaged))
  156. .pipe(print(log.created))
  157. ;
  158. });
  159. gulp.task('package uncompressed docs js', function() {
  160. return gulp.src(docsOutput.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(docsOutput.packaged))
  167. .pipe(print(log.created))
  168. ;
  169. });
  170. gulp.task('package compressed docs js', function() {
  171. return gulp.src(docsOutput.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(docsOutput.packaged))
  179. .pipe(print(log.created))
  180. ;
  181. });
  182. };