Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. var gulp = require('gulp');
  2. var imagemin = require('gulp-imagemin');
  3. var uncss = require('gulp-uncss');
  4. var rename = require('gulp-rename');
  5. var concat = require('gulp-concat');
  6. var uglify = require('gulp-uglify');
  7. var minify = require('gulp-minify-css');
  8. var browserSync = require('browser-sync').create();
  9. var zip = require('gulp-zip');
  10. var responsive = require('gulp-responsive');
  11. var load = require('gulp-load-plugins')();
  12.  
  13. gulp.task('resize-img', function () {
  14. return gulp.src('img/*.{jpg,png}')
  15. .pipe(load.responsive({
  16. '*.jpg': [{
  17. width: 100,
  18. rename: {
  19. suffix: '-thumb',
  20. }
  21. }, {
  22. width: 300,
  23. rename: {
  24. suffix: '-medium',
  25. // extname: '.jpg',
  26. },
  27. }, {
  28. width: 900,
  29. rename: {
  30. suffix: '-big',
  31. },
  32. // Do not enlarge the output image if the input image are already less than the required dimensions.
  33. withoutEnlargement: true,
  34. }],
  35.  
  36. '*.png': [{
  37. width: 100,
  38. rename: {
  39. suffix: '-thumb',
  40. }
  41. }, {
  42. width: 300,
  43. rename: {
  44. suffix: '-medium',
  45. // extname: '.jpg',
  46. },
  47. }, {
  48. width: 900,
  49. rename: {
  50. suffix: '-big',
  51. },
  52. // Do not enlarge the output image if the input image are already less than the required dimensions.
  53. withoutEnlargement: true,
  54. }]
  55.  
  56. }, {
  57. // Global configuration for all images
  58. // The output quality for JPEG, WebP and TIFF output formats
  59. quality: 70,
  60. // Use progressive (interlace) scan for JPEG and PNG output
  61. progressive: true,
  62. // Strip all metadata
  63. withMetadata: false,
  64. // Do not emit the error when image is enlarged.
  65. errorOnEnlargement: false,
  66. }))
  67. .pipe(gulp.dest('img/dist'));
  68. });
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. // ZIP-ARCHIVES
  79. gulp.task('zip', function(){
  80. gulp.src('./img/*')
  81. .pipe(zip('archive.zip'))
  82. .pipe(gulp.dest('download'))
  83. });
  84. //ZIP-ARCHIVES
  85.  
  86. // BROWSER-SYNC
  87. gulp.task('browser-sy', function() {
  88. browserSync.init({
  89. server: {
  90. baseDir: ''
  91. },
  92. })
  93. })
  94. // BROWSER-SYNC
  95.  
  96. // MINIFIC-IMGS
  97. gulp.task('build-img', function(){
  98. gulp.src('img/**/*')
  99. .pipe(imagemin())
  100. .pipe(gulp.dest('img'));
  101. })
  102. // MINIFIC-IMGS
  103.  
  104. // CONCACTENE-JS
  105. gulp.task('build-js', function(){
  106. gulp.src('js/*.js')
  107. .pipe(concat('all.js'))
  108. .pipe(gulp.dest('js/test/'))
  109. })
  110. // CONCACTENE-JS
  111. gulp.task('minifi-js', function(){
  112. gulp.src('js/test/all.js')
  113. .pipe(concat('final.min.js'))
  114. .pipe(uglify())
  115. .pipe(gulp.dest('js'))
  116. });
  117.  
  118. // BUILD-CSS
  119. gulp.task('build-css', function(){
  120. gulp.src('css/*.css')
  121. .pipe(concat('all.css'))
  122. .pipe(gulp.dest('css'))
  123. });
  124. // BUILD-CSS
  125.  
  126. // UNCSS
  127. gulp.task('un-css', function () {
  128. return gulp.src('css/all.css')
  129. .pipe(uncss({
  130. html: ['*.html'],
  131. js: ['*.js']
  132. }))
  133. .pipe(rename('final-clean.css'))
  134. .pipe(gulp.dest('css/final'))
  135. });
  136. // UNCSS
  137.  
  138. // MINIFIC-CSS
  139. gulp.task('minifi-css', function(){
  140. gulp.src('css/final/final-clean.css')
  141. .pipe(concat('minific.min.css'))
  142. .pipe(uglify())
  143. .pipe(gulp.dest('css'))
  144. });
  145. // MINIFIC-CSS
  146.  
  147. // TOPTOPTOP
  148. gulp.task('css', function(){
  149. gulp.src('css/*.css')
  150. .pipe(concat('master.min.css'))
  151. .pipe(uncss({
  152. html: ['*.html'],
  153. js: ['*.js']
  154. }))
  155. .pipe(minify())
  156. .pipe(gulp.dest('css'));
  157. });
  158. // TOPTOPTOP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement