You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Absolute path works for me locally but absolute paths are problematic in Vercel and I couldn't get to work there. Here is one such hack to force Vercel to include js file in bundle and reference it through absolute path, but this doesn't work for me:
importpathfrom'node';import{LoggerOptions,TransportTargetOptions,pino}from'pino';consttransportAbsolutePath=path.join(process.cwd(),'/lib/transport.mjs');consttargets: TransportTargetOptions[]=[{target: 'pino-pretty',level: 'info',options: {colorize: true}},];// breaks both locally and in VercelconsttransportRelativePath='../transport.mjs';// breaks in Vercel, can't find file on that pathtargets.push({target: transportAbsolutePath,level: 'info',options: {}});constdestination=pino.transport({ targets });constpinoOptions: LoggerOptions={enabled: true,timestamp: pino.stdTimeFunctions.isoTime,};exportconstlogger=pino(pinoOptions,destination);
I have tried to use CopyWebpackPlugin to include transport.js file in the bundle and reference it by absolute path but again it works locally and breaks in Vercel.
I have also tried to load transport through PinoWebpackPlugin and not through code but it doesn't even compile in dev as soon as I import it.
next.config.js
// it breaks build on this importconst{ PinoWebpackPlugin }=require('pino-webpack-plugin');constnextConfig={reactStrictMode: true,webpack(config,options){config.plugins.push(newPinoWebpackPlugin({transports: ['pino-pretty',path.join(__dirname,'lib/logger/transport.mjs'),],}));returnconfig;},};
Do you know some way I can load this transport in Vercel in Next.js app?
The text was updated successfully, but these errors were encountered:
In the
Readme.md
you load transport file via relative path, with Next.js this breaks for me in both local dev environment and Vercel prod:Absolute path works for me locally but absolute paths are problematic in Vercel and I couldn't get to work there. Here is one such hack to force Vercel to include js file in bundle and reference it through absolute path, but this doesn't work for me:
vercel/next.js#32236 (reply in thread)
Here is my code:
transport.mjs
I have tried to use
CopyWebpackPlugin
to includetransport.js
file in the bundle and reference it by absolute path but again it works locally and breaks in Vercel.next.config.js
I have also tried to load transport through
PinoWebpackPlugin
and not through code but it doesn't even compile in dev as soon as I import it.next.config.js
Do you know some way I can load this transport in Vercel in Next.js app?
The text was updated successfully, but these errors were encountered: