forked from flatlogic/sing-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
85 lines (73 loc) · 2.16 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
'use strict';
const gulp = require('gulp');
const del = require('del');
const sass = require('gulp-sass');
const rename = require ('gulp-rename');
const hb = require('gulp-hb');
const layouts = require('handlebars-layouts');
const srcPaths = {
scripts: ['./src/js/**/*'],
fonts: ['./src/fonts/**/*'],
images: ['./src/img/**/*'],
styles: ['./src/sass/*.scss'],
cssEntries: ['./src/sass/application.scss'],
static: ['./src/demo/**/*'],
templates: [
'src/*.hbs',
'src/pages/**/*.hbs'
],
partials: ['./src/partials/*.hbs'],
helpers: [
'./node_modules/handlebars-layouts/index.js',
'./src/helpers/index.js'
]
};
hb.handlebars.registerHelper(layouts(hb.handlebars));
gulp.task('clean', () => {
del(['dist']);
});
// Copy demo, img, js, fonts folders from src to dist
gulp.task('copy', ['copy:js'], function () {
gulp.src(srcPaths.static)
.pipe(gulp.dest('dist/demo'));
gulp.src(srcPaths.images)
.pipe(gulp.dest('dist/img'));
gulp.src(srcPaths.fonts)
.pipe(gulp.dest('dist/fonts'));
});
gulp.task('copy:js', function () {
gulp.src(srcPaths.scripts)
.pipe(gulp.dest('dist/js'));
});
// Handle handlebars
gulp.task('hbs', function () {
gulp.src(srcPaths.templates)
.pipe(hb({
partials: srcPaths.partials,
helpers: srcPaths.helpers
}))
.pipe(rename({extname: ".html"}))
.pipe(gulp.dest('dist'));
});
// Handle sass
gulp.task('styles', function () {
gulp.src(srcPaths.styles)
.pipe(sass({
precision: 10
}).on('error', sass.logError))
.pipe(gulp.dest('./dist/css'));
gulp.src(srcPaths.cssEntries)
.pipe(sass({
precision: 10,
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist/css'));
});
// Development
gulp.task('watch', ['build'], function () {
gulp.watch(srcPaths.scripts, ['copy:js']);
gulp.watch(srcPaths.styles, ['styles']);
gulp.watch([...srcPaths.templates, ...srcPaths.partials], ['hbs']);
});
gulp.task('build', ['hbs', 'styles', 'copy']);