Exploring the world of CSS Houdini in my Next.js project has been quite an adventure. After successfully installing the necessary CSS Houdini package and css-paint-polyfill
using yarn
, I decided to follow the webpack guidelines provided at .
Below is a snippet from my component:
import 'css-paint-polyfill';
import workletURL from 'url-loader!css-houdini-lines';
import styles from './Separator.module.css';
CSS.paintWorklet.addModule(workletURL);
export default function Separator() {
return <div className={styles.separator} />;
}
Despite my efforts, I encountered the infamous error message:
error - ReferenceError: window is not defined
at /home/tithos/code/web/new-tim/node_modules/css-paint-polyfill/dist/css-paint-polyfill.js:1:239
Attempting different solutions like placing the import for css-paint-polyfill
in a useEffect hook or experimenting with dynamic imports (as suggested on https://nextjs.org/docs/advanced-features/dynamic-import) only led to more errors. Is there anyone out there who has managed to resolve this issue?