-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix build error when the theme changes component style #53
base: main
Are you sure you want to change the base?
Conversation
The arco-plugins/packages/unplugin-react/src/plugins/theme.ts Lines 35 to 50 in 80eb24a
But when I look back at the existing sourcecode, I recall what make this problem happen: The unplugin turn to inject independent module rules instead of modifing properties of normal modules (it caused really much issues). And so that we deprecated the modifyVars option field:
It also mean that we doesn't support inject tokens from custom theme implicitly. arco-plugins/packages/plugin-webpack-react/src/arco-design-plugin/plugin-for-theme.ts Lines 33 to 75 in 80eb24a
However the automatic injection is not a required feature for every theme. I think that theme package should import token definitions by themself. This is also what the default theme of arco do. So that we didn't find the bug out before. But there is a workaround way. I left a util here: arco-plugins/packages/unplugin-react/src/utils/theme.ts Lines 33 to 41 in 80eb24a
You can use it just like: module.exports = {
module: {
rules: [
{
type: 'css',
test: /\.less$/,
use: [
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true,
},
modifyVars: {
...getThemeVars('@arco-design/theme-christmas'),
}
},
},
],
},
],
},
}; You can try it can give some feedback. |
Types of changes
Background and context
It will cause error when building an Arco theme with custom component style.
Solution
The reason for the problem is that the
token.less
file is not imported byAppendLoader
, so I import 'token.less' in each component style files.How is the change tested?
Just add a example with a arco theme
@arco-design/theme-christmas
.Changelog
Checklist:
feature
branch and others should be submitted tomaster
branch)Other information