When using a complete copy of with-ant-design-less sample, styles are loaded after an initial page render when nextjs is built to production
Steps to reproduce the behavior, please provide code snippets or a repository:
Styles should be loaded before initial render

I tried to deploy using my nextjs app using now and same issue is happening.
Overriding _app.js is a way to fix it !
Not sure this would help, but I import Antd in the following way, without messing up with the webpack config:
styles/antd.less:
@import "../../node_modules/antd/dist/antd.less";
@import "./antd-variables.less";
next.config.js:
const withPlugins = require("next-compose-plugins");
const less = require("@zeit/next-less");
module.exports = withPlugins([
[less, { lessLoaderOptions: { javascriptEnabled: true } }]
]);
_app.js:
import "../styles/antd/antd.less";
...
This seems to work just fine.
Overriding _app.js is a way to fix it !
No really working... For exemple, when i'm using Drawer from ant design, transition isn't working.
I am experiencing the same problem. Request a solution. help me
不确定这是否有帮助,但我可以通过以下方式导入Antd,而不会弄乱webpack配置:
styles/antd.less:@import "../../node_modules/antd/dist/antd.less"; @import "./antd-variables.less";
next.config.js:const withPlugins = require(“ next-compose-plugins ”); const less = require(“ @ zeit / next-less ”); 模块。出口 = withPlugins([ [less,{lessLoaderOptions : {javascriptEnabled : true }}] ]);
_app.js:导入 “ ../styles/antd/antd.less ” ; ...这似乎工作正常。
My latest experiment, doesn't work
Examples bug report
Describe the bug
When using a complete copy of with-ant-design-less sample, styles are loaded after an initial page render when nextjs is built to production
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to https://github.com/zeit/next.js/tree/canary/examples/with-ant-design-less
- Clone the repository
- Install dependencies and build in production mode
- Start in production mode
Expected behavior
Styles should be loaded before initial render
Screenshots
System information
- OS: macOS
- Browser (if applies) chrome
- Version of Next.js: latest
Additional context
I tried to deploy using my nextjs app using now and same issue is happening.
Has your problem been solved?
I manage to find a temporary solution by not putting style element in Next.Js Head. I don't know why, but when putting style element in Head, it is working at initial render but when navigation between page using Link (from next/link), style element is happened again in the tree.
return (
<Layout className="custom-layout">
{/* Fixes flash of unstyled content for first load, not in NextJs because causing issue */}
<style
id='holderStyle'
dangerouslySetInnerHTML={{
__html: `
*, *::before, *::after {
transition: none!important;
}
`
}}
/>
{/* Enf fixing flash unstyled content */}
<Head>
{/* SEO */}
....
</Head>
<Component {...pageProps} />
</Layout>
);
}
And before exporting my class
if (typeof window !== "undefined") {
window.onload = () => {
document.getElementById("holderStyle").remove();
};
}
@cfaure004 is the solution still working for you? I tried but, the Antd still loads with a flash....
@cfaure004 is the solution still working for you? I tried but, the Antd still loads with a flash....
Yes it's working well using my previous comment !
Duplicate of #9830
Most helpful comment
I am experiencing the same problem. Request a solution. help me