customize-cra icon indicating copy to clipboard operation
customize-cra copied to clipboard

CRA v4 switch from GenerateSW to InjectManifest not supported - workaround

Open nealeu opened this issue 4 years ago • 0 comments

In https://github.com/facebook/create-react-app/pull/9205, they switched to InjectManifest, yet at https://github.com/arackaf/customize-cra/blob/master/src/customizers/webpack.js#L64 we have

export const adjustWorkbox = adjust => config => {
  config.plugins.forEach(p => {
    if (p.constructor.name === "GenerateSW") {
      adjust(p.config);
    }
  });
  return config;
};

This needs amending to support adjusting the InjectManifest config which people needing to work around this issue can do by using the following code locally instead of importing adjustWorkbox:

export const adjustWorkbox = adjust => config => {
  config.plugins.forEach(p => {
    if (p.constructor.name === "InjectManifest") {
      adjust(p.config);
    }
  });
  return config;
};

nealeu avatar Aug 10 '21 17:08 nealeu