Closed semoonpark closed 1 year ago
your variables.less
is in __ROOT__/styles/
dir? or __ROOT__/src/styles/
?
try change to lessVarsFilePath: './src/styles/variables.less'
is working?
at root/styles
When I use the modifyVars
option with lessVarsToJs
, it works well.
const themeVariables = lessToJs(
fs.readFileSync(path.resolve(__dirname, './styles/variables.less'), 'utf8'),
)
/**
* @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
nx: {
svgr: true,
},
images: {
disableStaticImages: true,
},
// lessVarsFilePath: './styles/variables.less',
modifyVars: themeVariables,
}
your
variables.less
is in__ROOT__/styles/
dir? or__ROOT__/src/styles/
?try change to
lessVarsFilePath: './src/styles/variables.less'
is working?
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:
@import '~antd/lib/style/themes/default.less';
@primary-color: black; // change antd primary-color
@background-color-base: black;
@layout-header-background: green;
// ..
you also need to set "lessVarsFilePathAppendToEndOffContent" in next.config.js to true:
module.exports = withAntdLess({
lessVarsFilePath: './src/styles/x.less',
lessVarsFilePathAppendToEndOfContent: 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!
@semoonpark based on your configuration, you are using nx, so you need to change
lessVarsFilePath: './styles/variables.less',
to
lessVarsFilePath: './apps/<your-apps-name>/styles/variables.less',
then it should works.
your
variables.less
is in__ROOT__/styles/
dir? or__ROOT__/src/styles/
? try change tolessVarsFilePath: './src/styles/variables.less'
is working?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:
@import '~antd/lib/style/themes/default.less'; @primary-color: black; // change antd primary-color @background-color-base: black; @layout-header-background: green; // ..
you also need to set "lessVarsFilePathAppendToEndOffContent" in next.config.js to true:
module.exports = withAntdLess({ lessVarsFilePath: './src/styles/x.less', lessVarsFilePathAppendToEndOfContent: 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!
your
variables.less
is in__ROOT__/styles/
dir? or__ROOT__/src/styles/
? try change tolessVarsFilePath: './src/styles/variables.less'
is working?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:
@import '~antd/lib/style/themes/default.less'; @primary-color: black; // change antd primary-color @background-color-base: black; @layout-header-background: green; // ..
you also need to set "lessVarsFilePathAppendToEndOffContent" in next.config.js to true:
module.exports = withAntdLess({ lessVarsFilePath: './src/styles/x.less', lessVarsFilePathAppendToEndOfContent: 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!
Thank you so much, after working on it for one day it finally worked.
I tried overwrite less vars in variables.less but it doesn't work at all.
In
next.config.js
In
.babelrc
In
styles/variables.less
And in the component
Test
In
pages/test.tsx
The button color is still the default one.
Is there anything missed that I have to add more?
Current environment is below
Edited
below configuration on
next.config.js
is working, so annoying