This is a fork of the grunt-sw-precache by Morris Allison. It contains recent changes to sw-precache and supports options like runtimeCache
A Grunt task for generating service workers using sw-precache.
grunt-sw-precache requires Grunt ~0.4.5
.
If you haven"t used Grunt before, please view the Getting Started guide. The guide explains how to create a Gruntfile, and how to install and use Grunt plugins.
if you want to use this fork of grunt-sw-precache, directly refer to this repo japrescott/grunt-sw-precache.git within your package.json
The options documented here are specific to grunt-sw-precache.
For all other options, please view the options documentation for sw-precache.
The base directory for the staticFileGlobs
and workerFileName
options.
Default is "./dist"
;
The file name of the generated service worker. This is joined with the baseDir
option.
Default is "service-worker.js"
;
If true
, a comment containing a human readable UTC timestamp will be appended to the service worker.
/* @preserve Thu, 01 Jan 1970 00:00:00 GMT */
Default is true
;
The same option as stripPrefix
in sw-precache, but has a different default value.
Default is baseDir + "/"
;
grunt.initConfig({
"sw-precache": {
options: {
cacheId: "your-package-name",
workerFileName: "sw.js",
verbose: true,
},
"default": {
staticFileGlobs: [
"css/**/*.css",
"font/**/*.{woff,ttf,svg,eot}",
"img/**/*.{gif,png,jpg}",
"js/**/*.js",
],
},
"develop": {
staticFileGlobs: [
"font/**/*.{woff,ttf,svg,eot}"
],
},
},
});
Released under the MIT license.