This repository has been archived by the owner on Jun 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
89 lines (78 loc) · 1.9 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
const beep = require('beepbeep'),
cache = require('gulp-cached'),
cssBase64 = require('gulp-css-base64'),
cssNano = require('gulp-cssnano'),
gulp = require('gulp'),
liveReload = require('gulp-livereload'),
plumber = require('gulp-plumber'),
sass = require('gulp-sass'),
sassGlob = require('gulp-sass-glob'),
webpack = require('webpack-stream');
const files = {
sass: ['styles/**/*.scss'],
js: [
'scripts/**/*.js',
'!scripts/dist/*.js'
],
php: [
'**/*.php',
'!vendor/**/*.*',
'!node_modules/**/*.*'
],
twig: ['templates/**/*.twig']
};
/**
* Error handling
*/
const gulp_src = gulp.src;
gulp.src = function() {
return gulp_src.apply(gulp, arguments)
.pipe(plumber(() => {
beep();
}));
};
gulp.task('base64', () => {
return gulp.src('node_modules/fancybox/dist/css/*.css')
.pipe(cssBase64())
.pipe(gulp.dest('node_modules/fancybox/dist/css/'));
});
gulp.task('sass', ['base64'], () => {
return gulp.src(files.sass)
.pipe(sassGlob())
.pipe(sass().on('error', sass.logError))
.pipe(cssNano({
autoprefixer: {
add: true,
browsers: ['> 0.1%']
},
discardComments: {
removeAll: true
}
}))
.pipe(gulp.dest('styles/dist/'))
.pipe(liveReload());
});
gulp.task('js', () => {
return gulp.src('scripts/main.js')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('scripts/dist/'))
.pipe(liveReload());
});
gulp.task('php', () => {
return gulp.src(files.php)
.pipe(cache('php'))
.pipe(liveReload());
});
gulp.task('twig', () => {
return gulp.src(files.twig)
.pipe(cache('twig'))
.pipe(liveReload());
});
gulp.task('default', () => {
gulp.watch(files.sass, ['base64', 'sass']);
gulp.watch(files.js, ['js']);
gulp.watch(files.php, ['php']);
gulp.watch(files.twig, ['twig']);
liveReload.listen();
});