diff --git a/packages/create-llama/templates/types/streaming/nextjs/next.config.json b/packages/create-llama/templates/types/streaming/nextjs/next.config.json
index 64b603e1e7b39bc331911c2f83a5d6ff0798b9e1..264e20ef32d0f82cadce202574ff63843479198a 100644
--- a/packages/create-llama/templates/types/streaming/nextjs/next.config.json
+++ b/packages/create-llama/templates/types/streaming/nextjs/next.config.json
@@ -3,13 +3,5 @@
     "outputFileTracingIncludes": {
       "/*": ["./cache/**/*"]
     }
-  },
-  "webpack": {
-    "resolve": {
-      "alias": {
-        "sharp$": false,
-        "onnxruntime-node$": false
-      }
-    }
   }
 }
diff --git a/packages/create-llama/templates/types/streaming/nextjs/next.config.mjs b/packages/create-llama/templates/types/streaming/nextjs/next.config.mjs
index f622453794ed50d2190ee348d19a91f861d19026..124122bfaad262a8e291f9114971600670b0d02d 100644
--- a/packages/create-llama/templates/types/streaming/nextjs/next.config.mjs
+++ b/packages/create-llama/templates/types/streaming/nextjs/next.config.mjs
@@ -1,13 +1,8 @@
 /** @type {import('next').NextConfig} */
 import fs from "fs";
-import _ from "lodash";
+import webpack from "./webpack.config.mjs";
 
 const nextConfig = JSON.parse(fs.readFileSync("./next.config.json", "utf-8"));
-const webpackConfig = _.cloneDeep(nextConfig.webpack);
-
-// webpack config must be a function in NextJS, to use a JSON as config, we merge the settings from next.config.json
-nextConfig.webpack = (config) => {
-  return _.merge(config, webpackConfig);
-};
+nextConfig.webpack = webpack;
 
 export default nextConfig;
diff --git a/packages/create-llama/templates/types/streaming/nextjs/webpack.config.mjs b/packages/create-llama/templates/types/streaming/nextjs/webpack.config.mjs
new file mode 100644
index 0000000000000000000000000000000000000000..57fa19cfeccb4c8a416f26250164abe46597ab94
--- /dev/null
+++ b/packages/create-llama/templates/types/streaming/nextjs/webpack.config.mjs
@@ -0,0 +1,10 @@
+// webpack config must be a function in NextJS that is used to patch the default webpack config provided by NextJS, see https://nextjs.org/docs/pages/api-reference/next-config-js/webpack
+export default function webpack(config) {
+  // See https://webpack.js.org/configuration/resolve/#resolvealias
+  config.resolve.alias = {
+    ...config.resolve.alias,
+    sharp$: false,
+    "onnxruntime-node$": false,
+  };
+  return config;
+}