navigation icon indicating copy to clipboard operation
navigation copied to clipboard

Styles are not loaded for SSR

Open DarkGenius opened this issue 1 year ago • 11 comments

DarkGenius avatar May 15 '24 14:05 DarkGenius

+1

longpoll avatar Jun 13 '24 20:06 longpoll

+1

vladislav805 avatar Jun 13 '24 20:06 vladislav805

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

Fatal1stZ avatar Jul 30 '24 18:07 Fatal1stZ

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

max-portador avatar Sep 26 '24 11:09 max-portador

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

Fatal1stZ avatar Sep 26 '24 12:09 Fatal1stZ

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.

vladislav805 avatar Sep 27 '24 06:09 vladislav805

+1

GoncharovV avatar Oct 28 '24 09:10 GoncharovV

+1

v8tenko avatar Dec 19 '24 19:12 v8tenko