fix(bundler-okam): prefer use lessLoader.modifyVars than theme #874
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题
mako 不兼容 umi 的使用方式,不支持 lessLoader.modifyVars。
分析
原有逻辑见 https://github.com/umijs/umi/blob/cd327af/packages/bundler-webpack/src/config/cssRules.ts#L26-L28 。
一个细节是,如果 lessLoader 下有配置 modifyVars,会覆盖 userConfig.theme 里的定义。所以这里有个选择,1)保持一致,2)改成扩展的形式,让 lessLoader.modifyVars 扩展 userConfig.theme。虽然感觉后者更好,但还是先保持一致吧,用 lessLoader.modifyVars 的毕竟少。
方案
修改 bundler-okam/index.js,逻辑如下。