Skip to content

Commit

Permalink
fix(core): fixed user's webpack config being overridden if the plugin…
Browse files Browse the repository at this point in the history
… is disabled [bump ver]
  • Loading branch information
DuCanhGH committed Jan 28, 2023
1 parent b7d3f31 commit ecc1fe7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .changeset/brave-bananas-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"@ducanh2912/next-pwa": patch
---

fix(core): fixed user's webpack config being overridden if the plugin is disabled

- Before this patch, the plugin used to override user-defined or other plugins' Webpack custom config because it early returned the config (without calling `nextConfig.webpack?.()`) if it was disabled. This fixes it by calling `nextConfig.webpack?.()` before doing anything else.

chore(types): changed `compilerOptions.moduleResolution` to `"nodeNext"`.

- This shouldn't impact users. It is only meant to force me to write `.js` at the end of import paths and stuff.

docs(README): refined main README.md

- Rewrote README.md to fix grammar issues and decouple tips into TIPS.md. I also fixed/removed some broken links.

chore(deps): ran deps:update-all

- Nothing too special...
7 changes: 4 additions & 3 deletions packages/next-pwa/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ const withPWAInit = (
...workbox
} = workboxOptions;

if (typeof nextConfig.webpack === "function") {
config = nextConfig.webpack(config, options);
}

Object.keys(workbox).forEach(
(key) =>
workbox[key as keyof typeof workbox] === undefined &&
Expand Down Expand Up @@ -451,9 +455,6 @@ const withPWAInit = (
config.plugins.push(workboxPlugin);
}
}
if (typeof nextConfig.webpack === "function") {
return nextConfig.webpack(config, options);
}
return config;
},
} as NextConfig),
Expand Down

0 comments on commit ecc1fe7

Please sign in to comment.