{"_id":"@anilanar/sw-precache-webpack-plugin","_rev":"4-20dafb29aea6ec82ae73847fa3a92aa2","name":"@anilanar/sw-precache-webpack-plugin","description":"Webpack plugin for using service workers","dist-tags":{"latest":"0.9.1-patched.2"},"versions":{"0.9.1-patched.1":{"name":"@anilanar/sw-precache-webpack-plugin","version":"0.9.1-patched.1","description":"Webpack plugin for using service workers","main":"lib/index.js","scripts":{"prepublish":"make build","version":"make changelog && git add -p CHANGELOG.md && git checkout CHANGELOG.md","test:unit":"make unit_test","test:integration":"make integration_test","test":"make test"},"engines":{"node":">=4.0.0"},"keywords":["webpack","plugin","precache","sw-precache","service","worker"],"tags":["webpack","plugin","precache","sw-precache","service","worker"],"repository":{"type":"git","url":"git+https://github.com/anilanar/sw-precache-webpack-plugin.git"},"author":{"name":"Will Farley","email":"a.will.farley@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/anilanar/sw-precache-webpack-plugin/issues"},"homepage":"https://github.com/anilanar/sw-precache-webpack-plugin#readme","peerDependencies":{"webpack":"^1 || ^2 || ^2.1.0-beta || ^2.2.0-beta"},"dependencies":{"del":"^2.2.2","sw-precache":"^5.0.0","uglify-js":"^2.8.5"},"devDependencies":{"ava":"^0.18.2","babel-cli":"^6.16.0","babel-eslint":"^7.1.1","babel-polyfill":"^6.23.0","babel-preset-latest":"^6.22.0","babel-preset-stage-0":"^6.22.0","babel-register":"^6.23.0","bluebird":"^3.4.7","eslint":"^3.16.1","git-release-notes":"1.0.0","mkdirp":"^0.5.1","sinon":"^1.17.7","webpack":"^2.2.1"},"ava":{"babel":"inherit","require":["babel-register","babel-polyfill"]},"gitHead":"95a58b48dc6483e4fb86f3b414177d126ab0b9e3","_id":"@anilanar/sw-precache-webpack-plugin@0.9.1-patched.1","_shasum":"367f2781db8d4b6363ad7e3a6fb0ca77e8f2c54f","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.2.1","_npmUser":{"name":"anilanar","email":"anilanar@hotmail.com"},"dist":{"shasum":"367f2781db8d4b6363ad7e3a6fb0ca77e8f2c54f","tarball":"https://registry.npmjs.org/@anilanar/sw-precache-webpack-plugin/-/sw-precache-webpack-plugin-0.9.1-patched.1.tgz","integrity":"sha512-g1z52pX4FYo4Ib3RrV91dmDdh4eedAJ1PuD4AYMWHKA/BvNsxljO588j1KKSG7RqayJJrsxs1piVP1XM5vwoFQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICtZ1oAD8Nfn31iHPJkjgr9905MVQePfLV8G40pv5hUKAiEAyDvRHWiVGC+0f+W36zpt0umn2zLySvXccxqIzv/iOMk="}]},"maintainers":[{"name":"anilanar","email":"anilanar@hotmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/sw-precache-webpack-plugin-0.9.1-patched.1.tgz_1491832642920_0.04291917523369193"}},"0.9.1-patched.2":{"name":"@anilanar/sw-precache-webpack-plugin","version":"0.9.1-patched.2","description":"Webpack plugin for using service workers","main":"lib/index.js","scripts":{"prepublish":"make build","version":"make changelog && git add -p CHANGELOG.md && git checkout CHANGELOG.md","test:unit":"make unit_test","test:integration":"make integration_test","test":"make test"},"engines":{"node":">=4.0.0"},"keywords":["webpack","plugin","precache","sw-precache","service","worker"],"tags":["webpack","plugin","precache","sw-precache","service","worker"],"repository":{"type":"git","url":"git+https://github.com/anilanar/sw-precache-webpack-plugin.git"},"author":{"name":"Will Farley","email":"a.will.farley@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/anilanar/sw-precache-webpack-plugin/issues"},"homepage":"https://github.com/anilanar/sw-precache-webpack-plugin#readme","peerDependencies":{"webpack":"^1 || ^2 || ^2.1.0-beta || ^2.2.0-beta"},"dependencies":{"del":"^2.2.2","@anilanar/sw-precache":"5.1.0-patched.1","uglify-js":"^2.8.5"},"devDependencies":{"ava":"^0.18.2","babel-cli":"^6.16.0","babel-eslint":"^7.1.1","babel-polyfill":"^6.23.0","babel-preset-latest":"^6.22.0","babel-preset-stage-0":"^6.22.0","babel-register":"^6.23.0","bluebird":"^3.4.7","eslint":"^3.16.1","git-release-notes":"1.0.0","mkdirp":"^0.5.1","sinon":"^1.17.7","webpack":"^2.2.1"},"ava":{"babel":"inherit","require":["babel-register","babel-polyfill"]},"gitHead":"a360b1c689ee381f2035db0069cd735c8cfb8abb","_id":"@anilanar/sw-precache-webpack-plugin@0.9.1-patched.2","_shasum":"296a48639911861dd24ab2d92c55a89570c87ee4","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.7.1","_npmUser":{"name":"anilanar","email":"anilanar@hotmail.com"},"dist":{"shasum":"296a48639911861dd24ab2d92c55a89570c87ee4","tarball":"https://registry.npmjs.org/@anilanar/sw-precache-webpack-plugin/-/sw-precache-webpack-plugin-0.9.1-patched.2.tgz","integrity":"sha512-Y0eE7LLSjcvhONp4rtqdJZmsGjlU23pDbUrNVgNeh3AybhX5ydJa2jT+2xkLGGIcGczJd5AJtSaSFWWq01P4mA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDNcHs82c4uYsAzarjKbpP47ObYfzc6MMidm7Ayl9EfGwIhAPyaRl10lRreXVt4Nn3CSgFIFycDGarjCbIc8NT/vCod"}]},"maintainers":[{"name":"anilanar","email":"anilanar@hotmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/sw-precache-webpack-plugin-0.9.1-patched.2.tgz_1491833204128_0.30838496214710176"}}},"readme":"SW Precache Webpack Plugin\n==========================\n[![NPM version][npm-img]][npm-url]\n[![NPM downloads][npm-downloads-img]][npm-url]\n[![Dependency Status][daviddm-img]][daviddm-url]\n[![CircleCI][circleci-img]][circleci-url]\n\n__`SWPrecacheWebpackPlugin`__ is a [webpack][webpack] plugin for using [service workers][sw-guide] to cache your external project dependencies. It will generate a service worker file using [sw-precache][sw-precache] and add it to your build directory.\n\n\nInstall\n-------\n```bash\nnpm install --save-dev sw-precache-webpack-plugin\n```\n\nBasic Usage\n-----------\n```javascript\nvar path = require('path');\nvar SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');\n\n\nmodule.exports = {\n  context: __dirname,\n\n  entry: {\n    main: path.resolve(__dirname, 'src/index'),\n  },\n\n  output: {\n    path: path.resolve(__dirname, 'src/bundles/'),\n    filename: '[name]-[hash].js',\n  },\n\n  plugins: [\n    new SWPrecacheWebpackPlugin(\n      {\n        cacheId: 'my-project-name',\n        filename: 'my-service-worker.js',\n        maximumFileSizeToCacheInBytes: 4194304,\n        minify: true,\n        runtimeCaching: [{\n          handler: 'cacheFirst',\n          urlPattern: /[.]mp3$/,\n        }],\n      }\n    ),\n  ]\n}\n```\n\nThis will generate a new service worker at `src/bundles/my-service-worker.js`.\nThen you would just register it in your application:\n\n```javascript\n(function() {\n  if('serviceWorker' in navigator) {\n    navigator.serviceWorker.register('/my-service-worker.js');\n  }\n})();\n```\n\n[Another example of registering a service worker is provided by GoogleChrome/sw-precache][sw-precache-registration-example]\n\nConfiguration\n-------------\nYou can pass a hash of configuration options to `SWPrecacheWebpackPlugin`:\n\n__plugin options__:\n* `filename`: `[String]` - Service worker filename, default is `service-worker.js`\n* `filepath`: `[String]` - Service worker path and name, default is to use `webpack.output.path` + `options.filename`. This will overried `filename`. *Warning: Make the service worker available in the same directory it will be needed. This is because the scope of the service worker is defined by the directory the worker exists.*\n* `staticFileGlobsIgnorePatterns`: `[RegExp]` - Define an optional array of regex patterns to filter out of staticFileGlobs (see below)\n* `mergeStaticsConfig`: `[boolean]` - Merge provided staticFileGlobs and stripPrefixMulti with webpack's config, rather than having those take precedence, default is false.\n* `minify`: `[boolean]` - Set to true to minify and uglify the generated service-worker, default is false.\n* `forceDelete`: `[boolean]` - Pass force option to del, default is false.\n\n[__`sw-precache` options__][sw-precache-options]:\n* `cacheId`: `[String]` - Not required but you should include this, it will give your service worker cache a unique name\n* `directoryIndex`: `[String]`\n* `dynamicUrlToDependencies`: `[Object<String,Array<String>]`\n* `handleFetch`: `[boolean]`\n* `ignoreUrlParametersMatching`: `[Array<Regex>]`\n* `importScripts`: `[Array<String>]` - Add [hash] if you want to import a file generated with webpack [hash] ex. ['dist/some-[hash].js']\n* `logger`: `[function]`\n* `maximumFileSizeToCacheInBytes`: `[Number]`\n* `navigateFallbackWhitelist`: `[Array<RegExp>]`\n* `replacePrefix`: `[String]` - Should only be used in conjunction with `stripPrefix`\n* `runtimeCaching`: `[Array<Object>]`\n* `staticFileGlobs`: `[Array<String>]` - Omit this to allow the plugin to cache all your bundles' emitted assets. If `mergeStaticsConfig=true`: this value will be merged with your bundles' emitted assets, otherwise this value is just passed to `sw-precache` and emitted assets won't be included.\n* `stripPrefix`: `[String]` - Same as `stripPrefixMulti[stripPrefix] = ''`\n* `stripPrefixMulti`: `[Object<String,String>]` - Omit this to use your webpack config's `output.path + '/': output.publicPath`. If `mergeStaticsConfig=true`, this value will be merged with your webpack's `output.path: publicPath` for stripping prefixes. Otherwise this property will be passed directly to `sw-precache` and Webpack's output path won't be replaced.\n* `templateFilePath`: `[String]`\n* `verbose`: `[boolean]`\n\n\n_Note that all configuration options are optional. `SWPrecacheWebpackPlugin` will by default use all your assets emitted by webpack's compiler for the `staticFileGlobs` parameter and your webpack config's `{[output.path + '/']: output.publicPath}` as the `stripPrefixMulti` parameter. This behavior is probably what you want, all your webpack assets will be cached by your generated service worker. Just don't pass any arguments when you initialize this plugin, and let this plugin handle generating your `sw-precache` configuration._\n\n\nExamples\n--------\nSee the [examples documentation][example-project] for more examples.\n\nThe simplest use case would be:\n```javascript\nmodule.exports = {\n  ...\n  plugins: [\n    new SWPrecacheWebpackPlugin(),\n  ],\n  ...\n}\n```\n\nHere's an example using one option from `sw-precache` (`cacheId`) with one option from `SWPrecacheWebpackPlugin` (`filename`) in a configuration hash:\n```javascript\nplugins: [\n  new SWPrecacheWebpackPlugin(\n    {\n      cacheId: \"my-project-name\",\n      filename: \"my-project-service-worker.js\",\n    }\n  ),\n]\n```\n\nHere's a more elaborate example with `mergeStaticsConfig: true` and `staticFileGlobsIgnorePatterns`. `mergeStaticsConfig: true` allows you to add some additional static file globs to the emitted ServiceWorker file alongside Webpack's emitted assets. `staticFileGlobsIgnorePatterns` can be used to avoid including sourcemap file references in the generated ServiceWorker.\n```javascript\nplugins: [\n  new SWPrecacheWebpackPlugin(\n    {\n      cacheId: \"my-project-name\",\n      filename: \"my-project-service-worker.js\",\n      staticFileGlobs: [\n        'src/static/img/**.*',\n        'src/static/styles.css',\n      ],\n      stripPrefix: 'src/static/', // stripPrefixMulti is also supported\n      mergeStaticsConfig: true, // if you don't set this to true, you won't see any webpack-emitted assets in your serviceworker config\n      staticFileGlobsIgnorePatterns: [/\\.map$/], // use this to ignore sourcemap files\n    }\n  ),\n]\n```\n\n\nWebpack Dev Server Support\n--------------------------\nCurrently `SWPrecacheWebpackPlugin` will not work with `Webpack Dev Server`. If you wish to test the service worker locally, you can use simple a node server [see example project][example-project] or `python SimpleHTTPServer` from your build directory. I would suggest pointing your node server to a different port than your usual local development port and keeping the precache service worker out of your [local configuration (example)][webpack-local-config-example].\n\n\nContributing\n------------\n\nInstall node dependencies:\n\n```\n  $ npm install\n```\n\nAdd unit tests for your new feature in `./test/plugin.spec.js`\n\n\nTesting\n-------\nTests are located in `./test`\n\nRun tests:\n```\n  $ npm t\n```\n\n\n\n\n<!--references-->\n[sw-guide]: https://github.com/goldhand/notes/blob/master/notes/service_workers.md \"Introduction to service workers\"\n[sw-precache]: https://github.com/GoogleChrome/sw-precache \"SW-Precache\"\n[sw-precache-options]: https://github.com/GoogleChrome/sw-precache#options-parameter \"SW-Precache Options\"\n[sw-precache-registration-example]: https://github.com/GoogleChrome/sw-precache/blob/5699e5d049235ef0f668e8e2aa3bf2646ba3872f/demo/app/js/service-worker-registration.js\n[example-project]: /examples/\n[webpack]: http://webpack.github.io/\n[webpack-local-config-example]: https://github.com/goldhand/cookiecutter-webpack/blob/986151474b60dc19166eba18156a1f9dbceecb98/%7B%7Bcookiecutter.repo_name%7D%7D/webpack.local.config.js \"Webpack local config example\"\n\n[npm-url]: https://npmjs.org/package/sw-precache-webpack-plugin\n[npm-img]: https://badge.fury.io/js/sw-precache-webpack-plugin.svg\n[npm-downloads-img]: https://img.shields.io/npm/dm/sw-precache-webpack-plugin.svg?style=flat-square\n[daviddm-img]: https://david-dm.org/goldhand/sw-precache-webpack-plugin.svg\n[daviddm-url]: https://david-dm.org/goldhand/sw-precache-webpack-plugin\n[circleci-img]: https://circleci.com/gh/goldhand/sw-precache-webpack-plugin.svg?style=svg\n[circleci-url]: https://circleci.com/gh/goldhand/sw-precache-webpack-plugin\n","maintainers":[{"name":"anilanar","email":"anilanar@hotmail.com"}],"time":{"modified":"2022-06-12T14:42:27.389Z","created":"2017-04-10T13:57:23.905Z","0.9.1-patched.1":"2017-04-10T13:57:23.905Z","0.9.1-patched.2":"2017-04-10T14:06:46.192Z"},"homepage":"https://github.com/anilanar/sw-precache-webpack-plugin#readme","keywords":["webpack","plugin","precache","sw-precache","service","worker"],"repository":{"type":"git","url":"git+https://github.com/anilanar/sw-precache-webpack-plugin.git"},"author":{"name":"Will Farley","email":"a.will.farley@gmail.com"},"bugs":{"url":"https://github.com/anilanar/sw-precache-webpack-plugin/issues"},"license":"ISC","readmeFilename":"README.md"}