This repository has been archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.babel.js
executable file
·71 lines (63 loc) · 1.8 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
const gulp = require('gulp')
const blok = require('gulp-blok')
const watch = require('gulp-watch')
const less = require('gulp-less')
const browserSync = require('browser-sync')
const source = require('vinyl-source-stream')
const browserify = require('browserify')
const reload = browserSync.reload
const config = require('./config.js')
const fs = require('fs')
if (config.blok.domain == 'INSERT_YOUR_DOMAIN') {
config.blok.domain = 'hello.me.storyblok.com'
}
if (config.blok.themeId == 'INSERT_SPACE_ID') {
config.blok.themeId = '40032'
}
gulp.task('deploy', function () {
return gulp.src('./views/**/*')
.pipe(blok(config.blok))
})
gulp.task('styles', function () {
return gulp.src('source/less/theme.less')
.pipe(less({ compress: true }))
.pipe(gulp.dest('./views/assets/'))
.pipe(browserSync.stream())
})
gulp.task('scripts', function () {
return browserify({
entries: 'source/js/scripts.js'
})
.bundle()
.pipe(source('scripts.js'))
.pipe(gulp.dest('views/assets/js'))
.pipe(browserSync.stream())
})
gulp.task('browsersync', function () {
browserSync({
port: 4200,
serveStatic: ['./views'],
proxy: {
target: 'https://' + config.blok.domain,
reqHeaders: function (config) {
return {
'accept-encoding': 'identity',
'agent': false,
'browsersyncblok': true
}
}
},
https: fs.existsSync('./cert.js') ? require('./cert') : false,
reloadDelay: 1000,
notify: true,
open: true,
logLevel: 'silent'
})
gulp.watch('views/**/*.liquid').on('change', reload)
gulp.watch('source/less/**/*.less', ['styles'])
gulp.watch('source/js/**/*.js', ['scripts'])
})
gulp.task('default', ['styles', 'scripts', 'browsersync'], function () {
return watch('./views/**/*')
.pipe(blok(config.blok))
})