Completed
Push — master ( 2fe304...829df3 )
by Mikołaj
02:18
created

gulp.task(ꞌdefaultꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
nop 0
1
require('es6-promise').polyfill();
2
3
var gulp = require('gulp');
4
var sourcemaps = require('gulp-sourcemaps');
5
var sass = require('gulp-sass');
6
var moduleImporter = require('sass-module-importer');
7
var autoprefixer = require('gulp-autoprefixer');
8
var gcmq = require('gulp-group-css-media-queries');;
9
var cleanCSS = require('gulp-clean-css');
10
var include = require('gulp-include');
11
var uglify = require('gulp-uglify');
12
var del = require('del');
13
var runSequence = require('run-sequence');
14
var srcThemesPath = './resources/themes/';
15
var destThemesPath = './public/assets/';
16
17
gulp.task('sass-dev', function() {
18
  return gulp.src([srcThemesPath + '**/*.scss'])
19
    .pipe(sourcemaps.init())
20
    .pipe(sass({ importer: moduleImporter() }).on('error', sass.logError))
21
    .pipe(sourcemaps.write('./'))
22
    .pipe(gulp.dest(destThemesPath));
23
});
24
25
gulp.task('sass-prod', function() {
26
  return gulp.src([srcThemesPath + '**/*.scss'])
27
    .pipe(sass({ importer: moduleImporter() }).on('error', sass.logError))
28
    .pipe(autoprefixer({
29
      browsers: ['last 2 versions'],
30
      cascade: false
31
    }))
32
    .pipe(gcmq())
33
    .pipe(cleanCSS({debug: true}, function(details) {
34
      console.log(details.name + ' before: ' + details.stats.originalSize);
35
      console.log(details.name + ' after: ' + details.stats.minifiedSize);
36
    }))
37
    .pipe(gulp.dest(destThemesPath));
38
});
39
40
gulp.task('js', function() {
41
  return gulp.src([srcThemesPath + '**/*.js'])
42
    .pipe(include())
43
    .pipe(include({
44
      includePaths: [__dirname + "/node_modules"]
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
45
    })).on('error', console.log)
46
    .pipe(uglify())
47
    .pipe(gulp.dest(destThemesPath));
48
});
49
50
gulp.task('clean', function() {
51
  return del.sync('./public/assets');
52
})
53
54
gulp.task('watch', function(){
55
  gulp.watch(srcThemesPath + '**/*.scss', ['sass-dev']);
56
  gulp.watch(srcThemesPath + '**/*.js', ['js']);
57
})
58
59
// Build Sequences
60
// ---------------
61
62
gulp.task('default', function() {
63
  runSequence('clean', ['sass-dev', 'js'], 'watch')
64
})
65
66
gulp.task('build', function() {
67
  runSequence('clean', ['sass-prod', 'js'])
68
})
69