Skip to content

Commit

Permalink
Merge pull request #2078 from KMalkowski/fix/watchOptions
Browse files Browse the repository at this point in the history
[GCOM-1247] | next-config watch options
  • Loading branch information
paales authored Nov 8, 2023
2 parents f205a23 + 88ccaf9 commit 85af3af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-games-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/next-config': patch
---

Added @graphcommerce packages in node_modules to nextjs watch options
4 changes: 4 additions & 0 deletions packagesDev/next-config/dist/withGraphCommerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ function withGraphCommerce(nextConfig, cwd) {
new RegExp(`^(.+?[\\/]node_modules[\\/])(?!${transpilePackages.join('|')})`),
],
};
config.watchOptions = {
...(config.watchOptions ?? {}),
ignored: new RegExp(`^((?:[^/]*(?:/|$))*)(.(git|next)|(node_modules[\\/](?!${transpilePackages.join('|')})))(/((?:[^/]*(?:/|$))*)(?:$|/))?`),
};
if (!config.resolve)
config.resolve = {};
config.resolve.alias = {
Expand Down
36 changes: 24 additions & 12 deletions packagesDev/next-config/src/withGraphCommerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ let graphcommerceConfig: GraphCommerceConfig

function domains(config: GraphCommerceConfig): DomainLocale[] {
return Object.values(
config.storefront.reduce((acc, loc) => {
if (!loc.domain) return acc

acc[loc.domain] = {
defaultLocale: loc.locale,
locales: [...(acc[loc.domain]?.locales ?? []), loc.locale],
domain: loc.domain,
http: process.env.NODE_ENV === 'development' || undefined,
} as DomainLocale

return acc
}, {} as Record<string, DomainLocale>),
config.storefront.reduce(
(acc, loc) => {
if (!loc.domain) return acc

acc[loc.domain] = {
defaultLocale: loc.locale,
locales: [...(acc[loc.domain]?.locales ?? []), loc.locale],
domain: loc.domain,
http: process.env.NODE_ENV === 'development' || undefined,
} as DomainLocale

return acc
},
{} as Record<string, DomainLocale>,
),
)
}

Expand Down Expand Up @@ -161,6 +164,15 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
],
}

config.watchOptions = {
...(config.watchOptions ?? {}),
ignored: new RegExp(
`^((?:[^/]*(?:/|$))*)(.(git|next)|(node_modules[\\/](?!${transpilePackages.join(
'|',
)})))(/((?:[^/]*(?:/|$))*)(?:$|/))?`,
),
}

if (!config.resolve) config.resolve = {}
config.resolve.alias = {
...config.resolve.alias,
Expand Down

0 comments on commit 85af3af

Please sign in to comment.