New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nuxtjs/workbox

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxtjs/workbox - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

<a name="0.3.0"></a>
# [0.3.0](https://github.com/nuxt/modules/compare/@nuxtjs/workbox@0.2.0...@nuxtjs/workbox@0.3.0) (2017-06-04)
### Features
* **workbox:** full offline support ([9ee7f8f](https://github.com/nuxt/modules/commit/9ee7f8f))
<a name="0.2.0"></a>

@@ -8,0 +19,0 @@ # [0.2.0](https://github.com/nuxt/modules/compare/@nuxtjs/workbox@0.1.0...@nuxtjs/workbox@0.2.0) (2017-06-02)

34

index.js
const path = require('path')
const workboxPlugin = require('workbox-webpack-plugin');
const fixUrl = url => url.replace(/(?!^)\/\//g, '/').replace(':/', '://') // // ~> /
const regexEscape = url => url.replace(/\//g, '\\/') // / ~> \/
const wildcardRegex = url => '/' + regexEscape(fixUrl(url + '/.*')) + '/' // [url] ~> /[escape_url]\/*/
const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0
module.exports = function nuxtWorkbox(options) {

@@ -10,4 +15,6 @@ if (this.options.dev) {

const swFileName = 'sw.js'
const publicPath = this.options.build.publicPath
const routerBase = this.options.router.base
const publicPath = isUrl(this.options.build.publicPath)
? this.options.build.publicPath
: fixUrl(routerBase + this.options.build.publicPath)

@@ -20,11 +27,24 @@ // Add webpack plugin. This plugin internally uses swBuild to generate sw file

swDest: path.resolve(this.options.srcDir, 'static', swFileName),
// navigateFallback: routerBase, // BUG
//navigateFallback: routerBase, // it has some BUGS
directoryIndex: '/',
cacheId: process.env.npm_package_name,
skipWaiting: true, // sw is being registered after onNuxtReady()
clientsClaim: true,
globPatterns: ['**\/*.{js,css}'],
cacheId: process.env.npm_package_name + '_' + process.env.npm_package_version,
skipWaiting: true, // sw is being registered after onNuxtReady()
clientsClaim: true, // the generated service worker will claim any currently open pages
globPatterns: ['**\/*.{js,css,html,json}'],
modifyUrlPrefix: {
'/': publicPath
}
},
runtimeCaching: [
// Cache other _nuxt resources runtime
// They are hashed by webpack so are safe to loaded by cacheFirst handler
{
urlPattern: wildcardRegex(publicPath),
handler: 'cacheFirst'
},
// Cache routes if offline
{
urlPattern: wildcardRegex(routerBase),
handler: 'networkFirst'
}
]
}, options)))

@@ -31,0 +51,0 @@

{
"name": "@nuxtjs/workbox",
"version": "0.2.0",
"version": "0.3.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc