Adds support for vendor style transpilation for next.js. Based on https://github.com/martpie/next-transpile-modules.
yarn add @freshcells/next-transpile-vendor-styles
In your nextjs.config.mjs
import { PHASE_PRODUCTION_SERVER } from 'next/constants.js'
export default async (phase) => {
if (phase === PHASE_PRODUCTION_SERVER) {
return { /* your nextjs config */ }
}
// Lazy load modules we require for the compilation only.
// This way we can later omit the package for production
const transpileVendorStyles = await import('@freshcells/next-transpile-vendor-styles')
return withTransform = transpileVendorStyles.default([
'@your-namespace/module-1',
'@your-namespace/module-2'
])
return withTransform({
/* your nextjs config */
})
}