try worker-loader in next config

This commit is contained in:
Ryan Di 2025-03-18 21:41:00 +11:00
parent 86e274d304
commit 828b9287c5

View file

@ -1,12 +1,25 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
distDir: "build",
typescript: {
// The ts config doesn't work with `jsx: preserve" and if updated to `react-jsx` it gets ovewritten by next js throwing ts errors hence I am ignoring build errors until this is fixed.
// next.config.js
module.exports = {
webpack(config, { isServer }) {
config.distDir = "build";
config.typescript = {
ignoreBuildErrors: true,
},
// This is needed as in pages router the code for importing types throws error as its outside next js app
transpilePackages: ["../"],
};
};
config.transpileModules = ["../"];
module.exports = nextConfig;
if (!isServer) {
config.module.rules.push({
test: /\.worker\.(js|ts)$/,
use: {
loader: "worker-loader",
options: {
// You can tweak the filename pattern here
filename: "static/chunks/[hash].worker.js",
},
},
});
}
return config;
},
};