This repository has been archived by the owner on Dec 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (53 loc) · 1.73 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
//gulpfile.js
var $ = require('gulp-load-plugins')()
var gulp = require('gulp');
var sass = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');
var preprocess = require('gulp-preprocess');
var rename = require('gulp-rename');
var packageJson = require('./package.json');
//style paths
var sassFiles = 'css/style.scss',
cssDest = 'css/';
gulp.task('default', ['style', 'generate-html', 'generate-php', 'generate-service-worker']);
gulp.task('style', function(){
gulp.src(sassFiles)
.pipe(sass().on('error', sass.logError))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest(cssDest));
});
gulp.task('generate-service-worker', function(callback) {
var path = require('path');
var swPrecache = require('sw-precache');
swPrecache.write('service-worker.js',{
cacheId: packageJson.name,
staticFileGlobs: [
'css/**.css',
'**.html',
'img/**.*',
'js/**.js',
'fonts/**.*'
],
importScripts: [
'js/dexie.min.js',
'js/suggestions-sync.js'
],
verbose: true,
runtimeCaching: [{
urlPattern: 'lookup.php',
handler: 'networkFirst'
}]
}, callback);
});
gulp.task('generate-html', function() {
gulp.src('template.html')
.pipe(preprocess()) //To set environment variables in-line
.pipe(rename('index.html'))
.pipe(gulp.dest('.'));
});
gulp.task('generate-php', function() {
gulp.src('template.html')
.pipe(preprocess({context: { PHP: true}})) //To set environment variables in-line
.pipe(rename('index.php'))
.pipe(gulp.dest('.'));
});