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.

226 lines
7.9 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. dedupe = require('gulp-dedupe'),
  17. gulpif = require('gulp-if'),
  18. header = require('gulp-header'),
  19. less = require('gulp-less'),
  20. minifyCSS = require('gulp-minify-css'),
  21. plumber = require('gulp-plumber'),
  22. print = require('gulp-print'),
  23. rename = require('gulp-rename'),
  24. replace = require('gulp-replace'),
  25. uglify = require('gulp-uglify'),
  26. // user config
  27. config = require('./../config/user'),
  28. docsConfig = require('./../config/docs'),
  29. // install config
  30. tasks = require('./../config/tasks'),
  31. release = require('./../config/project/release'),
  32. // shorthand
  33. globs = config.globs,
  34. assets = config.paths.assets,
  35. output = config.paths.output,
  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(dedupe())
  48. .pipe(replace(assets.uncompressed, assets.packaged))
  49. .pipe(concatCSS(filenames.concatenatedCSS))
  50. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  51. .pipe(header(banner, settings.header))
  52. .pipe(gulp.dest(output.packaged))
  53. .pipe(print(log.created))
  54. ;
  55. });
  56. gulp.task('package compressed css', function() {
  57. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  58. .pipe(plumber())
  59. .pipe(dedupe())
  60. .pipe(replace(assets.uncompressed, assets.packaged))
  61. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  62. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  63. .pipe(minifyCSS(settings.concatMinify))
  64. .pipe(header(banner, settings.header))
  65. .pipe(gulp.dest(output.packaged))
  66. .pipe(print(log.created))
  67. ;
  68. });
  69. gulp.task('package uncompressed js', function() {
  70. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignored + '.js')
  71. .pipe(plumber())
  72. .pipe(dedupe())
  73. .pipe(replace(assets.uncompressed, assets.packaged))
  74. .pipe(concat(filenames.concatenatedJS))
  75. .pipe(header(banner, settings.header))
  76. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  77. .pipe(gulp.dest(output.packaged))
  78. .pipe(print(log.created))
  79. ;
  80. });
  81. gulp.task('package compressed js', function() {
  82. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignored + '.js')
  83. .pipe(plumber())
  84. .pipe(dedupe())
  85. .pipe(replace(assets.uncompressed, assets.packaged))
  86. .pipe(concat(filenames.concatenatedMinifiedJS))
  87. .pipe(uglify(settings.concatUglify))
  88. .pipe(header(banner, settings.header))
  89. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  90. .pipe(gulp.dest(output.packaged))
  91. .pipe(print(log.created))
  92. ;
  93. });
  94. /*--------------
  95. RTL
  96. ---------------*/
  97. if(config.rtl) {
  98. gulp.task('package uncompressed rtl css', function () {
  99. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  100. .pipe(dedupe())
  101. .pipe(replace(assets.uncompressed, assets.packaged))
  102. .pipe(concatCSS(filenames.concatenatedRTLCSS))
  103. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  104. .pipe(header(banner, settings.header))
  105. .pipe(gulp.dest(output.packaged))
  106. .pipe(print(log.created))
  107. ;
  108. });
  109. gulp.task('package compressed rtl css', function () {
  110. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  111. .pipe(dedupe())
  112. .pipe(replace(assets.uncompressed, assets.packaged))
  113. .pipe(concatCSS(filenames.concatenatedMinifiedRTLCSS))
  114. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  115. .pipe(minifyCSS(settings.concatMinify))
  116. .pipe(header(banner, settings.header))
  117. .pipe(gulp.dest(output.packaged))
  118. .pipe(print(log.created))
  119. ;
  120. });
  121. gulp.task('package uncompressed docs css', function() {
  122. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  123. .pipe(dedupe())
  124. .pipe(plumber())
  125. .pipe(replace(assets.uncompressed, assets.packaged))
  126. .pipe(concatCSS(filenames.concatenatedCSS))
  127. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  128. .pipe(gulp.dest(output.packaged))
  129. .pipe(print(log.created))
  130. ;
  131. });
  132. gulp.task('package compressed docs css', function() {
  133. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  134. .pipe(dedupe())
  135. .pipe(plumber())
  136. .pipe(replace(assets.uncompressed, assets.packaged))
  137. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  138. .pipe(minifyCSS(settings.concatMinify))
  139. .pipe(header(banner, settings.header))
  140. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  141. .pipe(gulp.dest(output.packaged))
  142. .pipe(print(log.created))
  143. ;
  144. });
  145. }
  146. /*--------------
  147. Docs
  148. ---------------*/
  149. var
  150. docsOutput = docsConfig.paths.output
  151. ;
  152. gulp.task('package uncompressed docs css', function() {
  153. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  154. .pipe(dedupe())
  155. .pipe(plumber())
  156. .pipe(replace(assets.uncompressed, assets.packaged))
  157. .pipe(concatCSS(filenames.concatenatedCSS))
  158. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  159. .pipe(gulp.dest(docsOutput.packaged))
  160. .pipe(print(log.created))
  161. ;
  162. });
  163. gulp.task('package compressed docs css', function() {
  164. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  165. .pipe(dedupe())
  166. .pipe(plumber())
  167. .pipe(replace(assets.uncompressed, assets.packaged))
  168. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  169. .pipe(minifyCSS(settings.concatMinify))
  170. .pipe(header(banner, settings.header))
  171. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  172. .pipe(gulp.dest(docsOutput.packaged))
  173. .pipe(print(log.created))
  174. ;
  175. });
  176. gulp.task('package uncompressed docs js', function() {
  177. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.js')
  178. .pipe(dedupe())
  179. .pipe(plumber())
  180. .pipe(replace(assets.uncompressed, assets.packaged))
  181. .pipe(concat(filenames.concatenatedJS))
  182. .pipe(header(banner, settings.header))
  183. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  184. .pipe(gulp.dest(docsOutput.packaged))
  185. .pipe(print(log.created))
  186. ;
  187. });
  188. gulp.task('package compressed docs js', function() {
  189. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.js')
  190. .pipe(dedupe())
  191. .pipe(plumber())
  192. .pipe(replace(assets.uncompressed, assets.packaged))
  193. .pipe(concat(filenames.concatenatedMinifiedJS))
  194. .pipe(uglify(settings.concatUglify))
  195. .pipe(header(banner, settings.header))
  196. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  197. .pipe(gulp.dest(docsOutput.packaged))
  198. .pipe(print(log.created))
  199. ;
  200. });
  201. };