The with-ant-design-less example is lack off hot reloading and client-side rendering for css
Steps to reproduce the behavior, please provide code snippets or a repository:
Hot reloading problem:
Client-side rendering for css:
I really appreciate if anyone can tell me the appropriate way to use Ant design in Next.js with custom less style with hot reloading, client-side rendering by answering the questions below:
style tag), but the ant design icon part not working.Hi @nenjamin2405, regarding your first issue, I got HMR of antd LESS overrides working by defining a custom pages/_document.js and moving the LESS import to pages/index.js. you can see a working example here: https://github.com/delikat/next.js/commit/b6cefcdbb15bb16ad70706ca28307b7ef126e266
Thanks for your support @delikat, but with that implementation, I already had a problem in page loading time (performance issue) while navigating between pages, due to the fact that it must repeatedly import a whole Antd less file in every single page. So I am really confused and wonder what is the proper way in using Antd that meet my above requirements (import and load ant design layout once in _app.js or _document.js, then each page has its own less file which doesn't contain ant design import in it).
wired, same problem
Any update on this?
quite painful, still issues...
So why not contribute to the example? 馃
@timneutkens - Yeah, I know good point. Been trying to figure this out. Looks like custom less is fine to compile with HMR, but the theme-ing (vars) with 'antd' has the HMR issue. Came across this article where I tried to implement the "yarn add antd-theme-webpack-plugin", but still not luck. Gonna do a working repo, hopefully once fixed..
Has anyone found a workaround?
We should be using modularized ant-design with this babel config:
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }]
I've been trying to get it to work but with no luck. With the inclusion of the "libraryDirectory": "es" it throws a build error. For example if I use the Layout component this error is thrown:
(function (exports, require, module, __filename, __dirname) { import Layout from './layout';
^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18) type: 'SyntaxError', '$error': '$error' }
I've been trying to make babel-preset-env work for it to work with es modules but it doesn't seem to work. Can anyone chime in?
Duplicate of #9830
Most helpful comment
We should be using modularized ant-design with this babel config:
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }]I've been trying to get it to work but with no luck. With the inclusion of the
"libraryDirectory": "es"it throws a build error. For example if I use the Layout component this error is thrown:I've been trying to make babel-preset-env work for it to work with es modules but it doesn't seem to work. Can anyone chime in?