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

@cojam/cra-append-sw

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cojam/cra-append-sw

Utility tool to append custom code to ServiceWorker created by Create React App

  • 2.8.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cra-append-sw

Fork of cra-append-sw, but with Typescript files support. See below.

Utility tool to append custom code to ServiceWorker created by Create React App.

It allows to keep the default CRA configuration (no ejecting). It simply appends custom code to the ServiceWorker file created by CRA build scripts. By default, it bundles the code using very basic Webpack+Babel configuration (this can be omitted; see options).

Installation

$ npm install @cojam/cra-append-sw --save

Usage

$ cra-append-sw [options] <file>

Options

-s, --skip-compile      Skip compilation
-h, --help              Output usage information
-e, --env [path]        (./.env) Path to environment variables file
-t, --tsconfig [path]   (./tsconfig.json) Path to tsconfig file
-m, --mode [mode]       Output mode
Output modes
  • dev creates public/<file> instead of appending the code to build/service-worker.js
  • build creates build/<file> instead of appending the code to build/service-worker.js
  • replace simply replaces build/service-worker.js

Usage with Create React App

In package.json modify build script to:

"start": "react-scripts start && cra-append-sw --mode dev ./custom-sw.js",
"build": "react-scripts build && cra-append-sw ./custom-sw.js",

Usage with Typescript

The file is compiled based on your tsconfig.json configuration. Please set these values for fields isolatedModules and noEmit:

{
    "compilerOptions": {
        "isolatedModules": false,
        "noEmit": false
    }
}

Keywords

FAQs

Package last updated on 24 Aug 2020

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

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