adrianhajdin / portfolio

Modern & Minimal JS Mastery Portfolio
https://minimal-portfolio-swart.vercel.app
2.24k stars 459 forks source link

Fix Build Error by Implementing Conditional Dynamic Import for Lottie #14

Closed mohsn-mirzaei closed 3 months ago

mohsn-mirzaei commented 4 months ago

Summary

This pull request fixes a build error by implementing a conditional dynamic import for Lottie.

Details

Changes


// Previous import
import Lottie from "react-lottie";

// New imports
import dynamic from "next/dynamic";
let Lottie;

if (process.env.NODE_ENV === "development") {
  Lottie = require("react-lottie").default;
} else {
  Lottie = dynamic(() => import("react-lottie"), { ssr: false });
}