Duration
6 min
Access
Pro
Transcript
Available

We take the opengraph image we wrote in codesandbox and copy it into our serverless function. We use Rollup to compile the component into an IIFE (immediately invoked function expression) that can run in our headless browser environment and cover a wide set of rollup plugins that we need for compatibility. We end the lesson having successfully screenshot our opengraph react component from our Netlify Function

Note: Due to Netlify changing their handling, the path in fs.readFileSync is affected. Update to:

const script = fs.readFileSync(path.resolve(__dirname, "image.js"), "utf-8");