lessVarsFilePath not works
See original GitHub issueI tried overwrite less vars in variables.less but it doesn’t work at all.
In next.config.js
const withNx = require('@nrwl/next/plugins/with-nx')
const withImages = require('next-images')
const withAntdLess = require('next-plugin-antd-less')
const nextConfig = {
nx: {
svgr: true,
},
images: {
disableStaticImages: true,
},
lessVarsFilePath: './styles/variables.less',
}
module.exports = withAntdLess(withImages(withNx(nextConfig)))
In .babelrc
{
"presets": [
"@nrwl/next/babel"
],
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": true
}
]
],
"ignore": [
"node_modules"
]
}
In styles/variables.less
@import '~antd/lib/style/themes/default.less';
@primary-color: #477593;
@border-radius-base: 5px;
@body-background: #f7f7f7;
And in the component Test
In pages/test.tsx
import {Button} from 'antd'
export const Test = () => (
<Button type='primary'>antd button</Button>
)
export default Test
The button color is still the default one.
Is there anything missed that I have to add more?
Current environment is below
"babel-plugin-import": "^1.13.3",
"next-plugin-antd-less": "^1.5.2",
"antd": "^4.16.13",
Edited
below configuration on next.config.js is working, so annoying
const nextConfig = {
nx: {
// Set this to false if you do not want to use SVGR
// See: https://github.com/gregberge/svgr
svgr: true,
},
// FIXME: https://github.com/twopluszero/next-images/issues/73 still got a problem on loading images
images: {
disableStaticImages: true,
},
lessVarsFilePath: './styles/variables.less', // not working
modifyVars: {'@primary-color': '#000000'}, // working
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
lessVarsFilePath doesn't work · Issue #74 - GitHub
Issue I'm trying to use next-plugin-antd-less according to the documentation, but my antd variables don't work.
Read more >How to configure Next.js with Antd / Less and Sass / CSS ...
I tried adding lessVarsFilePath to next.config.js (like what we need to do for next-plugin-antd-less), but it has no effect. – ...
Read more >How to use Ant Design with Next.js - LogRocket Blog
By doing this, we import the Ant Design component styles globally and are not required to import each component individually. Ant Design also ......
Read more >How to set up Ant Design with Next.js - Albin Groen
In this article we'll be covering how to make Ant Design with custom theming work flawlessly together with Next.js. Start by setting up...
Read more >How to Customize Ant Design Theme in a Next.js App
... Or better still you can specify a path to a file lessVarsFilePath: '. ... So make sure it's not imported elsewhere.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

so even just adding a containing folder named whatever in root and place my styles folder inside of it (for e.g. as per your suggestion ./src/styles/x.less rather than ./styles/x.less), the function “additionalData” defined on line 328 of overrideWebpackConfig.js actually fires (this should be easily fixed and probably shouldn’t be happening right…?) for anyone confused about this.
if your antd variables .less file at (after changing path) ./src/styles/x.less as commonly recommended looks something like this:
you also need to set “lessVarsFilePathAppendToEndOffContent” in next.config.js to true:
and then the variables at ./src/styles/x.less will be applied correctly
i’m assuming this should be pretty easy to fix & clean up so it’s easier for people to work with but i don’t have the time to contribute this myself currently.
thank you for the great project & work though!
at
root/stylesWhen I use the
modifyVarsoption withlessVarsToJs, it works well.