Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. // npm modules
  4. const gulp = require('gulp');
  5. const compass = require('gulp-compass');
  6. const concat = require('gulp-concat');
  7. const uglify = require('gulp-uglify');
  8. const cleanCSS = require('gulp-clean-css');
  9. const del = require('del');
  10.  
  11. //path constants
  12. const assetsPath = './resources/assets/';
  13. const bowerPath = assetsPath + 'bower_components';
  14. const adminPath = bowerPath + '/gentelella';
  15.  
  16. const publicPath = './public/';
  17. const publicCSS = publicPath + 'css/';
  18. const publicJS = publicPath + 'js/';
  19. const publicFonts = publicPath + 'fonts/';
  20.  
  21.  
  22. gulp.task('clean', function () {
  23.     return del([
  24.         publicCSS + '/*.css',
  25.         publicJS + '/*.js',
  26.         publicFonts + '/*',
  27.         publicPath + '/vendors/**/*'
  28.     ]);
  29. });
  30.  
  31.  
  32. gulp.task('base', function () {
  33.     gulp.src([
  34.             bowerPath + '/bootstrap/dist/css/bootstrap.css',
  35.             bowerPath + '/bootstrap/dist/css/bootstrap-theme.css',
  36.             bowerPath + '/font-awesome/css/font-awesome.css'
  37.         ])
  38.         .pipe(concat('base.css'))
  39.         .pipe(cleanCSS({compatibility: '*'}))
  40.         .pipe(gulp.dest(publicCSS));
  41.  
  42.  
  43.     gulp.src([
  44.             bowerPath + '/jquery/dist/jquery.js',
  45.             bowerPath + '/bootstrap/dist/js/bootstrap.js'
  46.         ])
  47.         .pipe(concat('base.js'))
  48.         .pipe(uglify())
  49.         .pipe(gulp.dest(publicJS));
  50.  
  51.  
  52.     return gulp.src([
  53.             adminPath + '/bootstrap/fonts/*',
  54.             adminPath + '/font-awesome/fonts/*'
  55.         ])
  56.         .pipe(gulp.dest(publicFonts))
  57. });
  58.  
  59.  
  60. //todo:витягти лише потрібні
  61. gulp.task('copyVendor', function () {
  62.     return gulp
  63.         .src(adminPath + '/vendors/**/*')
  64.         .pipe(gulp.dest(publicPath + '/vendors'));
  65. });
  66.  
  67. gulp.task('admin', gulp.parallel('copyVendor', function () {
  68.     gulp
  69.         .src([
  70.             adminPath + '/build/css/custom.min.css'
  71.         ])
  72.         .pipe(concat('admin.css'))
  73.         .pipe(gulp.dest(publicCSS));
  74.  
  75.     return gulp
  76.         .src([
  77.             adminPath + '/build/js/custom.min.js'
  78.         ])
  79.         .pipe(concat('admin.js'))
  80.         .pipe(gulp.dest(publicJS));
  81.  
  82. }));
  83.  
  84. gulp.task('frontend', function () {
  85.  
  86.     gulp.src([
  87.         assetsPath+'js/common.js'
  88.     ])
  89.         .pipe(concat('common.js'))
  90.         .pipe(uglify())
  91.         .pipe(gulp.dest(publicJS));
  92.  
  93.     return gulp
  94.         .src(assetsPath + '/sass/styles.scss')
  95.         .pipe(compass({
  96.             config_file: assetsPath + '/sass/config.rb',
  97.             css: publicCSS,
  98.             sass: assetsPath + '/sass',
  99.             image: publicPath + '/img',
  100.             logging: true
  101.         }))
  102.         .pipe(gulp.dest(publicCSS));
  103. });
  104.  
  105.  
  106. gulp.task('default', gulp.series('clean', gulp.parallel('base', 'admin', 'frontend')));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement