This repository has been archived by the owner on Sep 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.babel.js
83 lines (67 loc) · 1.95 KB
/
gulpfile.babel.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
'use strict';
import gulp from 'gulp';
import gulpLoadPlugins from 'gulp-load-plugins';
import runSequence from 'run-sequence';
import browserSync from 'browser-sync';
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
// Template
// ========
gulp.task('template_test', () => {
return gulp.src('test/src/index.html.twig')
.pipe($.twig())
.pipe($.extReplace('.html', '.html.html'))
.pipe($.prettify({ indent_size: 2 }))
.pipe(gulp.dest('test/dest'));
});
const report_error = error => {
$.notify({
title: 'An error occured with a Gulp task',
message: 'Check you terminal for more informations'
}).write(error);
console.log(error.toString());
this.emit('end');
};
// Style
// =====
const scssCompilation = (src, dest) => {
return gulp.src(src)
.pipe($.sourcemaps.init())
.pipe($.sass({
precision: 6,
indentWidth: 4,
}))
.on('error', report_error)
.pipe($.autoprefixer({
browsers: [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
]
}))
.pipe($.sourcemaps.write())
.pipe(gulp.dest(dest));
}
gulp.task('style_test', () => {
scssCompilation('./test/src/style.scss', './test/dest')
});
gulp.task('style_dest', () => {
scssCompilation('./test/src/trowel-drops.scss', './dest/css')
});
gulp.task('style', ['style_test', 'style_dest']);
gulp.task('default', ['style', 'template_test']);
gulp.task('watch', ['default'], () => {
browserSync({
notify: false,
logPrefix: 'Trowel Cards',
server: ['test/dest']
});
gulp.watch('./**/*.scss', ['style', reload]);
gulp.watch(['test/src/**/*.html.twig', 'src/twig/**/*.html.twig'], ['template_test', reload]);
});