All Projects â†’ davejm â†’ react-app-rewire-workbox

davejm / react-app-rewire-workbox

Licence: MIT License
Customise the service worker for create-react-app apps without ejecting - using Google's Workbox webpack plugins instead of the old sw-precache

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-app-rewire-workbox

chicio.github.io
đŸ‘ģ Fabrizio Duroni (me 😄) personal website. Created using GatsbyJS, Styled Components, Storybook, Typescript, tsParticles, GitHub pages, Github Actions, Upptime.
Stars: ✭ 20 (-54.55%)
Mutual labels:  service-worker, progressive-web-app, workbox
speedy-math
An application which allows user (small kids) to practice basic Mathematics operations
Stars: ✭ 28 (-36.36%)
Mutual labels:  create-react-app, progressive-web-app, workbox
Pwatter
Angular Progressive Web App using Workbox
Stars: ✭ 167 (+279.55%)
Mutual labels:  service-worker, progressive-web-app, workbox
jekyll-pwa-workbox
A Jekyll plugin using Workbox to make your PWA / Website available offline.
Stars: ✭ 22 (-50%)
Mutual labels:  service-worker, progressive-web-app, workbox
next-with-workbox
Higher order Next.js config to generate service workers
Stars: ✭ 22 (-50%)
Mutual labels:  service-worker, progressive-web-app, workbox
Parcel Plugin Sw Cache
đŸ“Ļ👷 Parcel plugin for caching using a service worker
Stars: ✭ 45 (+2.27%)
Mutual labels:  service-worker, progressive-web-app, workbox
So Pwa
A progressive web app to read Stack Overflow content.
Stars: ✭ 235 (+434.09%)
Mutual labels:  service-worker, progressive-web-app, workbox
Create React Pwa
https://github.com/facebookincubator/create-react-app + Progressive Web App goodness
Stars: ✭ 1,268 (+2781.82%)
Mutual labels:  service-worker, create-react-app, progressive-web-app
react-app-rewire-webpack-bundle-analyzer
Add webpack-bundle-analyzer to a react-app-rewired config.
Stars: ✭ 24 (-45.45%)
Mutual labels:  create-react-app, react-app-rewire, react-app-rewired
Productivity Frontend
Productivity Application - Kanban Style Productivity Management Application with Customizable Boards, Lists and Cards to Make You More Productive.
Stars: ✭ 234 (+431.82%)
Mutual labels:  service-worker, progressive-web-app
Jfa Pwa Toolkit
⚡ī¸ PWA Features to Any Website (very Fast & Easy)
Stars: ✭ 245 (+456.82%)
Mutual labels:  service-worker, progressive-web-app
spendlogs
SpendLogs - Personal Expense Manager
Stars: ✭ 18 (-59.09%)
Mutual labels:  service-worker, progressive-web-app
Ember Service Worker
A pluggable approach to Service Workers for Ember.js
Stars: ✭ 227 (+415.91%)
Mutual labels:  service-worker, progressive-web-app
Progressive Weather App
A local weather app that fetches weather forecast from Openweathermap.org. A Progressive Web App built with Vue.js.
Stars: ✭ 223 (+406.82%)
Mutual labels:  service-worker, progressive-web-app
magento-meanbee-pwa
Progressive Web App extension for Magento 1
Stars: ✭ 75 (+70.45%)
Mutual labels:  service-worker, progressive-web-app
affilicats
🐈 Progressive Web App demo that showcases flaky network resilience measures (đŸ“ļ or đŸšĢđŸ“ļ).
Stars: ✭ 65 (+47.73%)
Mutual labels:  service-worker, progressive-web-app
cra-multi-page-template
Create-react-app Multi-page application configuration template, including dva and ant-design, enabled PWA, compatible with IE11.
Stars: ✭ 17 (-61.36%)
Mutual labels:  create-react-app, react-app-rewired
Generator Jekyll Starter Kit
🚀 Jekyll Progressive Web App Generator.
Stars: ✭ 139 (+215.91%)
Mutual labels:  service-worker, progressive-web-app
webdash-workbox
Webdash workbox helps you generate your webdash configuration & gives you service worker stats.
Stars: ✭ 25 (-43.18%)
Mutual labels:  service-worker, workbox
java-pwa
Progressive Web Apps in Java
Stars: ✭ 48 (+9.09%)
Mutual labels:  service-worker, progressive-web-app

react-app-rewire-workbox

npm

Add the workbox-webpack-plugin to your create-react-app app via react-app-rewired without having to eject OR fork.

By default, create react app uses SWPrecacheWebpackPlugin under the hood to generate a service worker which pre-caches your app shell and assets. sw-precache and sw-toolbox are being phased out in favour of Workbox so ideally we'd like to use Workbox instead!

Create react app also doesn't let you customise your service worker AT ALL! This plugin allows you to easily use the GenerateSW and InjectManifest functions from Workbox Webpack plugin. See here for details on the configuration options for each method.

This plugin will remove the SWPrecacheWebpackPlugin from the Webpack plugin configuration and add the Workbox GenerateSW and InjectManifest plugin with your desired configuration.

Installation

yarn add workbox-webpack-plugin # OR npm install --save workbox-webpack-plugin
yarn add react-app-rewire-workbox # OR npm install --save react-app-rewire-workbox

# If you don't have it already already, you also need:
yarn add react-app-rewired # OR npm install --save react-app-rewired

Usage

  1. In the config-overrides.js of the root of your project you created for react-app-rewired add this code (this example uses the GenerateSW version of Workbox for easy pre-caching functionality):
/* config-overrides.js */
const {rewireWorkboxGenerate} = require('react-app-rewire-workbox');

module.exports = function override(config, env) {
  if (env === "production") {
    console.log("Production build - Adding Workbox for PWAs");
    config = rewireWorkboxGenerate()(config, env);
  }

  return config;
};
  1. Replace 'react-scripts' with 'react-app-rewired' in package.json
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom"
  },

That's it, you now have Workbox for all your service worker / 'progressive web app' needs!!

Advanced Usage / Configuration

Two functions are exported from this module: rewireWorkboxGenerate and rewireWorkboxInject. For info on how each Webpack plugin works, see the Google documentation.

If you call either function with no parameters, it will set a default configuration that works well with create-react-app. If you would like to add a custom config, pass it in as the parameter e.g.

const {rewireWorkboxInject, defaultInjectConfig} = require('react-app-rewire-workbox');
const path = require('path');

module.exports = function override(config, env) {
  if (env === "production") {
    console.log("Production build - Adding Workbox for PWAs");
    // Extend the default injection config with required swSrc
    const workboxConfig = {
      ...defaultInjectConfig,
      swSrc: path.join(__dirname, 'src', 'custom-sw.js')
    };
    config = rewireWorkboxInject(workboxConfig)(config, env);
  }

  return config;
};

For your convenience the default configs for both functions are also exported so you can easily override them. They are exported as defaultGenerateConfig and defaultInjectConfig.

License

Licensed under the MIT License, Copyright Šī¸ 2018 David Moodie. See LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].