-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use with react-app-rewired #41
Comments
Heya, |
If anyone else ends up here, I was able to get it working by slightly modifying @hbj's config (CRA2 has support for SCSS out of the box) EDIT: spoke too soon... overriding color variables works, but importing them doesn't. If anyone has figured it out, please share. const { injectBabelPlugin, getLoader } = require('react-app-rewired');
const rewireLess = require('react-app-rewire-less');
const AntdScssThemePlugin = require('antd-scss-theme-plugin');
module.exports = function override(config, env) {
console.log('overriding!')
config = injectBabelPlugin(
['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
config
);
// add less support to antd
config = rewireLess.withLoaderOptions({
javascriptEnabled: true
})(config, env);
config.plugins.push(new AntdScssThemePlugin('./theme.scss'));
// override the less loader to use the ones from AntdScssThemePlugin
themify(config, '.less', 'less-loader');
return config;
};
// override a loader with the one from AntdScssThemePlugin
function themify(config, ext, loaderName) {
const rule = getLoader(
config.module.rules,
rule => rule.test && rule.test.test(ext)
);
const loader =
rule && rule.use && rule.use.find(item => item.loader === loaderName);
if (loader) {
Object.assign(loader, AntdScssThemePlugin.themify(loader));
}
} |
I have been here recently. I found out that if the themes.scss file has multi-line comments, the parsing from SCSS to JSON will fail. |
Could that be cause of you need to wrap SASS loader as you did with LESS? https://github.com/intoli/antd-scss-theme-plugin#step-2-use-antd-scss-theme-plugin-in-your-webpack-setup |
In case this helps anyone else, this is my config with It's a bit rough, but it's a start:
As with @ghost, I am finding that only overriding variables is working. There are some other issues that I'm not sure are to do with this config or not.
|
Still an issue. |
Can anyone help with this? The above solutions are not working.
|
@MildTomato I have encountered that error at times as well, depending on what's in my If you're okay with dealing with the limitations, I'd suggest testing to see if it works for you with just one override, say for |
@uturnr cheers 🚀 I don't think I was using any imports at all, think I had it with just one variable. The import thing isn't really much of an issue, i suppose the same same scss variables could be used elsewhere, so it's not all bad 😄 got this weird feeling that I might had been using less syntax in |
@uturnr so, I progressed it a little bit. Now I'm getting this error haha
|
@MildTomato Maybe it is trying to use |
Got it working! Anyone got any tips to make antd-scss-theme-plugin work with GatsbyJS? |
@MildTomato , How to you get it to work? |
Oh, got it working. There's some funny stuff that comes up with formatting of scss.
the above fails to compile. but if you comment the 1st line like.. |
I was able to get it working with |
Don't know if this is the only problem at play, but I was able to get this to work by changing the theme path that gets passed to the plugin constructor to an absolute path ( |
could you perhaps share your |
I'm trying to use the plugin with 'react-app-rewired' and I have succeeded to use it to customize the theme, but if I import
theme.scss
and try to use Ant Design's variables I get 'Undefined variable' errors (I can only use the ones I have defined in the file).Here is my
config-overrides.js
file:The text was updated successfully, but these errors were encountered: