Skip to content
Snippets Groups Projects
Commit fe473571 authored by Marcus Schiesser's avatar Marcus Schiesser Committed by GitHub
Browse files

refactor: use a function for webpack config (#634)

parent 6001b2f8
No related branches found
No related tags found
No related merge requests found
...@@ -3,13 +3,5 @@ ...@@ -3,13 +3,5 @@
"outputFileTracingIncludes": { "outputFileTracingIncludes": {
"/*": ["./cache/**/*"] "/*": ["./cache/**/*"]
} }
},
"webpack": {
"resolve": {
"alias": {
"sharp$": false,
"onnxruntime-node$": false
}
}
} }
} }
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
import fs from "fs"; 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 nextConfig = JSON.parse(fs.readFileSync("./next.config.json", "utf-8"));
const webpackConfig = _.cloneDeep(nextConfig.webpack); nextConfig.webpack = 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);
};
export default nextConfig; export default nextConfig;
// 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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment