build(config): add custom externals mapping for @napi-rs/canvas in server webpack
Configure webpack to treat @napi-rs/canvas as an external dependency under the 'canvas' module name when building the server bundle. This adjustment ensures proper module resolution and avoids bundling native dependencies directly, improving deployment reliability for environments requiring @napi-rs/canvas.
This commit is contained in:
parent
2d205008ef
commit
3258c04ac6
1 changed files with 8 additions and 0 deletions
|
|
@ -80,6 +80,14 @@ const nextConfig: NextConfig = {
|
|||
],
|
||||
},
|
||||
webpack: (config, { isServer }) => {
|
||||
if (isServer) {
|
||||
config.externals = [
|
||||
...(config.externals || []),
|
||||
{
|
||||
canvas: 'commonjs @napi-rs/canvas',
|
||||
},
|
||||
];
|
||||
}
|
||||
if (isServer && bundleWorkerCompute) {
|
||||
config.resolve.alias = {
|
||||
...(config.resolve.alias || {}),
|
||||
|
|
|
|||
Loading…
Reference in a new issue