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.

213 lines
7.6 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/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(header(banner, settings.header))
  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(gulpif(config.hasPermission, chmod(config.permission)))
  60. .pipe(minifyCSS(settings.concatMinify))
  61. .pipe(header(banner, settings.header))
  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.concatUglify))
  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. if(config.rtl) {
  93. gulp.task('package uncompressed rtl css', function () {
  94. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  95. .pipe(replace(assets.uncompressed, assets.packaged))
  96. .pipe(concatCSS(filenames.concatenatedRTLCSS))
  97. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  98. .pipe(header(banner, settings.header))
  99. .pipe(gulp.dest(output.packaged))
  100. .pipe(print(log.created))
  101. ;
  102. });
  103. gulp.task('package compressed rtl css', function () {
  104. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignoredRTL + '.rtl.css')
  105. .pipe(replace(assets.uncompressed, assets.packaged))
  106. .pipe(concatCSS(filenames.concatenatedMinifiedRTLCSS))
  107. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  108. .pipe(minifyCSS(settings.concatMinify))
  109. .pipe(header(banner, settings.header))
  110. .pipe(gulp.dest(output.packaged))
  111. .pipe(print(log.created))
  112. ;
  113. });
  114. gulp.task('package uncompressed docs css', function() {
  115. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  116. .pipe(plumber())
  117. .pipe(replace(assets.uncompressed, assets.packaged))
  118. .pipe(concatCSS(filenames.concatenatedCSS))
  119. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  120. .pipe(gulp.dest(output.packaged))
  121. .pipe(print(log.created))
  122. ;
  123. });
  124. gulp.task('package compressed docs css', function() {
  125. return gulp.src(output.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  126. .pipe(plumber())
  127. .pipe(replace(assets.uncompressed, assets.packaged))
  128. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  129. .pipe(minifyCSS(settings.concatMinify))
  130. .pipe(header(banner, settings.header))
  131. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  132. .pipe(gulp.dest(output.packaged))
  133. .pipe(print(log.created))
  134. ;
  135. });
  136. }
  137. /*--------------
  138. Docs
  139. ---------------*/
  140. var
  141. docsOutput = docsConfig.paths.output
  142. ;
  143. gulp.task('package uncompressed docs css', function() {
  144. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  145. .pipe(plumber())
  146. .pipe(replace(assets.uncompressed, assets.packaged))
  147. .pipe(concatCSS(filenames.concatenatedCSS))
  148. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  149. .pipe(gulp.dest(docsOutput.packaged))
  150. .pipe(print(log.created))
  151. ;
  152. });
  153. gulp.task('package compressed docs css', function() {
  154. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.css')
  155. .pipe(plumber())
  156. .pipe(replace(assets.uncompressed, assets.packaged))
  157. .pipe(concatCSS(filenames.concatenatedMinifiedCSS))
  158. .pipe(minifyCSS(settings.concatMinify))
  159. .pipe(header(banner, settings.header))
  160. .pipe(gulpif(config.hasPermission, chmod(config.permission)))
  161. .pipe(gulp.dest(docsOutput.packaged))
  162. .pipe(print(log.created))
  163. ;
  164. });
  165. gulp.task('package uncompressed docs js', function() {
  166. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.js')
  167. .pipe(plumber())
  168. .pipe(replace(assets.uncompressed, assets.packaged))
  169. .pipe(concat(filenames.concatenatedJS))
  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 compressed docs js', function() {
  177. return gulp.src(docsOutput.uncompressed + '/**/' + globs.components + globs.ignored + '.js')
  178. .pipe(plumber())
  179. .pipe(replace(assets.uncompressed, assets.packaged))
  180. .pipe(concat(filenames.concatenatedMinifiedJS))
  181. .pipe(uglify(settings.concatUglify))
  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. };