# create-cloudinary-service-worker

> Cloudinary Service Worker starter kit

Latest version **0.3.0** (published 2020-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install create-cloudinary-service-worker
pnpm add create-cloudinary-service-worker
yarn add create-cloudinary-service-worker
bun add create-cloudinary-service-worker
```

Provides the command `create-cloudinary-service-worker`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2020-09-23 |
| First published | 2020-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cloudinary |
| Maintainers | mbryla |

## Links

- npm: https://www.npmjs.com/package/create-cloudinary-service-worker
- npm.io page: https://npm.io/package/create-cloudinary-service-worker

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [yargs](https://npm.io/package/yargs.md) ^16.0.3

## Recent versions

- 0.3.0 (latest) — 2020-09-23
- 0.2.0 — 2020-09-23
- 0.1.1 — 2020-09-23
- 0.1.0 — 2020-09-23

## README

## Using service workers with Cloudinary!

### What's inside?
The main directory consists of an `index.js` script and the `templates` directory containing service worker file and its configuration.

This is published to NPM as `create-cloudinary-service-worker` allowing it to be run with the `npx` or `yarn create` commands.

Example:
```bash
yarn create cloudinary-service-worker
npx create-cloudinary-service-worker
```

Those commands will copy the service worker files to the desired location (working directory by default, can be overriden with `-p` | `--path` parameter).

Example:
```bash
yarn create cloudinary-service-worker --path my-app/src
npx create-cloudinary-service-worker --path my-app/src
```

The script accepts also a `--verbose` flag to provide additional runtime information. See `--help` for more options.

### Demo project
Besides the main package this repository contains also the demo application showing the example use case. It includes a small website with images that does not use Cloudinary. You can run it locally, use the `create-cloudinary-service-worker` script and enable it to see the difference.

In order to check it yourself please clone this repository and run the following.

```bash
cd demo
yarn
yarn start

# if you prefer to use npm please run the following
cd demo
npm install
npm start
```

You should have a working page without service workers running locally. In order to enhance it with the power of the Cloudinary service worker run the following:

```bash
yarn create cloudinary-service-worker

# if you prefer to use npm please run the following
npx create-cloudinary-service-worker
```

The service worker is now copied to your (demo) project directory. Please edit `index.html` and add the service worker setup script `cloudinaryServiceWorkerSetup.js`.

```html
<script src="./cloudinaryServiceWorkerSetup.js"></script>
```

You're done! Once you refresh the page the service worker should be registered. Once you refresh the page for the second time all assets will be served through cloudinary. You can edit the config JSON inside the `cloudinaryServiceWorkerSetup.js` file to customize the behaviour.

---
_Source: https://npm.io/package/create-cloudinary-service-worker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
