Skip to content
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

🧐[问题]从umi换成vite构建后,ConfigProvider 提供的主题在 ProComponents失效 #8743

Open
YeZiyii opened this issue Sep 25, 2024 · 1 comment

Comments

@YeZiyii
Copy link

YeZiyii commented Sep 25, 2024

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🧐 问题描述

换成vite构建后,发现项目中ProComponents的样式都有问题了,检查发现是组件的cssVar没有生效,antd的组件都是正常的。找不到办法解决,求大佬指点,拜托了!!

💻 vite配置如下

import svgr from '@svgr/rollup';
import react from '@vitejs/plugin-react-swc';
import { GitRevisionPlugin } from 'git-revision-webpack-plugin';
import { resolve } from 'path';
import { defineConfig } from 'vite';
import loadCssModulePlugin from 'vite-plugin-load-css-module';
import proxy from './config/proxy';

const {
REACT_APP_ENV,
UMI_ENV,
CI_COMMIT_TAG,
CI_COMMIT_SHA,
CI_COMMIT_REF_NAME,
CI_COMMIT_TIMESTAMP,
} = process.env;

const gitRevisionPlugin = new GitRevisionPlugin();

function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir);
}

export default defineConfig({
base: '/',
plugins: [
react(),
svgr(),
loadCssModulePlugin({
include: (id) => {
return id.endsWith('.less') && !id.includes('node_modules') && id !== './global.less';
},
}),
],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
additionalData: @import "${pathResolve('src/global.less')}";,
},
},
},
define: {
UMI_ENV: JSON.stringify(UMI_ENV),
REACT_APP_ENV: JSON.stringify(REACT_APP_ENV),
'process.env': {
git: JSON.stringify({
version: CI_COMMIT_TAG ?? gitRevisionPlugin.version(),
commitHash: CI_COMMIT_SHA ?? gitRevisionPlugin.commithash(),
branch: CI_COMMIT_REF_NAME ?? gitRevisionPlugin.branch(),
lastCommitDateTime: CI_COMMIT_TIMESTAMP ?? gitRevisionPlugin.lastcommitdatetime(),
buildAt: new Date(),
}),
},
},
resolve: {
alias: [
{ find: '@', replacement: pathResolve('src') },
{ find: 'moment', replacement: 'dayjs' },
{ find: '~@', replacement: pathResolve('src') },
{ find: '@umijs/max', replacement: pathResolve('src/plugins') },
// 兼容 @nekit/request @nekit/auth 中的引用
{ find: 'umi', replacement: pathResolve('src/plugins') },
],
},
server: {
host: true,
open: true,
port: 8000,
hmr: true,
proxy: proxy[REACT_APP_ENV || 'dev'],
},
});

🚑如图

圈起来的部分都是procomponents

image

@YeZiyii YeZiyii changed the title 🧐[问题]从umi换成vite构建后,ProComponents的组件的cssVar失效 🧐[问题]从umi换成vite构建后,ConfigProvider 提供的主题在 ProComponents失效 Sep 25, 2024
@fnoopv
Copy link
Contributor

fnoopv commented Oct 22, 2024

https://ant.design/docs/react/migrate-less-variables-cn, 使用了废弃的变量?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants