![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
next-offline
Advanced tools
Use [sw-precache](https://github.com/GoogleChrome/sw-precache) with [Next.js](https://github.com/zeit/next.js)
Use sw-precache with Next.js
npm install --save next-offline
or
yarn add next-offline
Create a next.config.js
in your project
// next.config.js
const withOffline = require('next-offline')
module.exports = withOffline()
Then create a server.js
// server.js
const { createServer } = require('http')
const next = require('next')
const { join } = require('path')
const app = next({ dev: process.env.NODE_ENV !== 'production' })
const handle = app.getRequestHandler()
app.prepare()
.then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true)
const { pathname } = parsedUrl
if (pathname === '/service-worker.js') {
const filePath = join(__dirname, '.next', pathname)
app.serveStatic(req, res, filePath)
} else {
handle(req, res, parsedUrl)
}
})
.listen(port, () => {
console.log(`> Ready on http://localhost:${port}`)
})
})
Optionally you can add your custom Next.js configuration as parameter
// next.config.js
const withOffline = require('next-offline')
module.exports = withOffline({
webpack(config, options) {
return config
}
})
The default object passed to sw-precache-webpack-plugin is here:
{
verbose: false,
minify: true,
staticFileGlobsIgnorePatterns: [/\.next\//],
runtimeCaching: [
{
handler: 'networkFirst',
urlPattern: /^https?.*/
}
]
}
It can easily be modified by passing a swPreCacheOptions
object to withOffline
in your next.config.js
// next.config.js
const withOffline = require('next-offline')
module.exports = withOffline({
swPreCacheOptions: {
verbose: true,
minify: false
}
})
By default next-offline
will register a service worker with the script below, this is automatically be add to your client side bundle once nextOffline
is invoked.
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/service-worker.js')
.then(registration => console.info('service worker registration successful'))
.catch(err => console.warn('service worker registration failed', err.message))
}
You can pass in your own custom service worker register script by using the registerPath
option like this:
// next.config.js
const withOffline = require('next-offline')
const { resolve } = require('path')
module.exports = withOffline({
swPreCacheOptions: {
registerPath: resolve(__dirname, 'my-service-worker.js')
}
})
Questions? Feedback? Please let me know
WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|
Copyright © 2017-present Jack Hanford, jackhanford@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
next-offline
The npm package next-offline receives a total of 2,604 weekly downloads. As such, next-offline popularity was classified as popular.
We found that next-offline demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.