rodrigograca31
4/25/2017 - 10:30 PM

Gulp Service Worker

Gulp Service Worker

// 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);
});