Created
April 25, 2017 22:30
-
-
Save rodrigograca31/8d0ba5ab48bb840f091d29a8202f97f6 to your computer and use it in GitHub Desktop.
Gulp Service Worker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://medium.com/google-developer-experts/add-offline-support-to-any-web-app-c20edc4bea0e | |
gulp.task('sw', function(callback) { | |
var path = require('path'); | |
var swPrecache = require('sw-precache'); | |
var fs = require('fs'); | |
var rootDir = folder; | |
//var options = require('./sw-precache-config.json'); | |
var options = JSON.parse(fs.readFileSync('./sw-precache-config.json', 'utf-8')); | |
options.ignoreUrlParametersMatching = [/./]; | |
options.cacheId += "-" + (new Date()).getTime(); | |
swPrecache.write(path.join(rootDir, 'sw.js'), options, callback); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment