How to configure T3 Stacks next.config + 'next-transpile-modules' (withTM) ?

I need to use next-transpile-modules in my t3 stack app, but not sure how to integrate it into my next.config file: The general recommendation is like this:
const withTM = require('next-transpile-modules')(['react-hook-mousetrap']);
module.exports = withTM({ /* Your Next.js config */ });
const withTM = require('next-transpile-modules')(['react-hook-mousetrap']);
module.exports = withTM({ /* Your Next.js config */ });
However, this doesn't work with the t3 next.config, though I'm sure I'm doing something wrong:
import { env } from "./src/env/server.mjs";

function defineNextConfig(config) {
return config;
}

const withTM = require('next-transpile-modules')(['react-hook-mousetrap']);

// module.exports = withTM({ /* Your Next.js config */ });

export default withTM(defineNextConfig({
reactStrictMode: true,
swcMinify: true,
// Next.js i18n docs: https://nextjs.org/docs/advanced-features/i18n-routing
i18n: {
locales: ["en"],
defaultLocale: "en",
},
webpack(config) {
config.resolve.fallback = {
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
// by next.js will be dropped. Doesn't make much sense, but how it is
fs: false, // the solution
};

return config;
},
}));
import { env } from "./src/env/server.mjs";

function defineNextConfig(config) {
return config;
}

const withTM = require('next-transpile-modules')(['react-hook-mousetrap']);

// module.exports = withTM({ /* Your Next.js config */ });

export default withTM(defineNextConfig({
reactStrictMode: true,
swcMinify: true,
// Next.js i18n docs: https://nextjs.org/docs/advanced-features/i18n-routing
i18n: {
locales: ["en"],
defaultLocale: "en",
},
webpack(config) {
config.resolve.fallback = {
...config.resolve.fallback, // if you miss it, all the other options in fallback, specified
// by next.js will be dropped. Doesn't make much sense, but how it is
fs: false, // the solution
};

return config;
},
}));
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server