gravity-ui / navigation

https://preview.gravity-ui.com/navigation
MIT License
24 stars 7 forks source link

Styles are not loaded for SSR #237

Open DarkGenius opened 4 months ago

longpoll commented 3 months ago

+1

vladislav805 commented 3 months ago

+1

Fatal1stZ commented 2 months ago

+1 https://stackblitz.com/edit/stackblitz-starters-nk24sk?file=app%2Flayout.tsx

max-portador commented 3 days ago

It`s Next.js problem - https://nextjs.org/docs/messages/css-npm

I found a solution for Next.js.

If you are using Next.js 13.1 or higher, you should define the transpilePackages option in next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
  transpilePackages: ['@gravity-ui/navigation', '@gravity-ui/uikit'],
};

module.exports = nextConfig;

Example: https://stackblitz.com/edit/stackblitz-starters-izlcht?file=next.config.js,app%2Flayout.tsx

Before Next.js 13 you can try next-transpile-modules

Fatal1stZ commented 3 days ago

@max-portador It's still "blinking" in your example, styles are properly loaded on the client side only.

vladislav805 commented 2 days ago

It`s Next.js problem

I don't use Next.js at all and the problem is the same. Moreover, the problem is that when this package building, the styles are bundled to JS, not to separate CSS files.