-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use webpack alias hack to suppress "msw/browser" imports
- Loading branch information
1 parent
f45cce8
commit eb017b0
Showing
4 changed files
with
32 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
experimental: { | ||
instrumentationHook: true | ||
} | ||
}; | ||
instrumentationHook: true, | ||
}, | ||
webpack(config, { isServer }) { | ||
/** | ||
* @fixme This is completely redundant. webpack should understand | ||
* export conditions and don't try to import "msw/browser" code | ||
* that's clearly marked as client-side only in the app. | ||
*/ | ||
if (isServer) { | ||
if (Array.isArray(config.resolve.alias)) { | ||
config.resolve.alias.push({ name: 'msw/browser', alias: false }) | ||
} else { | ||
config.resolve.alias['msw/browser'] = false | ||
} | ||
} else { | ||
if (Array.isArray(config.resolve.alias)) { | ||
config.resolve.alias.push({ name: 'msw/node', alias: false }) | ||
} else { | ||
config.resolve.alias['msw/node'] = false | ||
} | ||
} | ||
|
||
export default nextConfig; | ||
return config | ||
}, | ||
} | ||
|
||
export default nextConfig |