New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

offlinejs-generator

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

offlinejs-generator

Generator for ServiceWorker serving static files

latest
Source
npmnpm
Version
1.1.4
Version published
Maintainers
1
Created
Source

offlinejs

A simple generator that crawls your build directory and creates a ServiceWorker and injects a loader script into the index.html

npm i -D offlinejs-generator

Can be configured by creating an offline.json in your project root and calling:

offlinejs

Use a different config with:

offlinejs other-config.json

options

attributedefaultdescription
path"dist"directory where your project build is generated
injectInto"dist/index.html"if the script should inject a loader script, if yes set it to "index.html" or the wanted target
template"offline.js"your ServiceWorker template
versionDate.now()your project build version (new version is required for a new release)
excludefalseregex as string to exclude specific files ( use [\\\\/] for slashed to make it OS independent)
include".*"control what is loaded (file paths have to pass the exclude and include test)
data{}a flat object containing any data you need in the template (injection marks in your template shall look like this: /*[data.apiPort]*/)

example offline.json:

{
  "path": "dist",
  "injectInto": false,
  "template": "offline.js",
  "exclude": "(assets[\\\\/]fonts[\\\\/].*)",
  "data": {
    "api": ":8080",
    "hostname": "localhost",
    "pushBadge": "http://localhost:4200/assets/push-badge.png"
  }
}

Don't forget you still need a manifest.json in your dist folder!

Keywords

serviceworker

FAQs

Package last updated on 08 Nov 2018

Did you know?

Socket

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.

Install

Related posts