Closed hui-zhao-1 closed 6 years ago
以下三个方案,任选其一 1.手动删除node_modules/.cache文件夹,可以处理这个问题 2.设置hardSource: false 3.升级umi到2.1
1.手动删除node_modules/.cache文件夹 确认可以解决问题 2.设置hardSource: false 确认可以解决问题 3.升级umi到2.1 升级到2.1.0没有解决问题 响应好快,感谢!
@xiaohuoni 删除cache目录和设置hardSource:true之后本地可以,但是npm run build出来的还是不行,怎么解。
@chaegumi 这个不是一个问题,你这个是样式覆盖的问题。这个问题应该已经修复了,不行的话加!important吧!
@xiaohuoni 本来是umi2.1现在升级到umi2.2.7还是不行,另外发现一个有意思的现象,可能我对那些less解析插件不了解,好像只要less中的css元素带有background*属性或者color,就会出现上边截图那样的情景。加important也没有效果。
@chaegumi https://github.com/umijs/umi/issues/1002 这个问题还没关闭。你说的现象,能给一个简易demo看看吗?如果跟这个问题不同,可以另开一个问题,讨论
@xiaohuoni 我全新安装一个ant design pro,window系统和mac系统都正常。window系统会把图片base64,mac系统是路径形式的。ant design pro升级git中搜索过,说要git pull,手动merge之后才能升级,也不知道是哪个组件差了,造成图片不正常。
图片小于10k会被转成base64
代码提交,删掉项目重新下载,重新install 就好了
{ "name": "ant-design-pro", "version": "4.5.0", "private": true, "description": "An out-of-box UI solution for enterprise applications", "scripts": { "analyze": "cross-env ANALYZE=1 umi build", "build": "umi build", "dev": "npm run start:dev", "start": "cross-env UMI_ENV=dev REACT_APP_ENV=dev UMI_UI=none umi dev", "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev", "start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev", "start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev", "start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev umi dev", "start:test": "cross-env REACT_APP_ENV=test MOCK=none UMI_ENV=dev umi dev" }, "browserslist": [ "> 1%", "last 2 versions", "not ie <= 10" ], "dependencies": { "@ant-design/icons": "^4.7.0", "@ant-design/pro-card": "^1.19.0", "@ant-design/pro-descriptions": "^1.10.0", "@ant-design/pro-form": "^1.60.0", "@ant-design/pro-layout": "^6.34.9", "@ant-design/pro-table": "^2.69.0", "@umijs/route-utils": "2.0.0", "antd": "4.19.4", "antd-img-crop": "^3.14.2", "classnames": "^2.2.6", "lodash": "^4.17.11", "moment": "^2.25.3", "omit.js": "^2.0.2", "rc-util": "^5.9.5", "react": "^16.14.0", "react-cropper": "^2.1.8", "react-dev-inspector": "^1.1.1", "react-dom": "^17.0.0", "react-helmet-async": "^1.0.4", "umi": "3.5.0", "swiper": "3", "umi-request": "^1.0.8", "wangeditor": "^4.7.5" }, "devDependencies": { "@ant-design/pro-cli": "^1.0.28", "@types/classnames": "^2.2.7", "@types/express": "^4.17.0", "@types/history": "^4.7.2", "@types/lodash": "^4.14.144", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@types/react-helmet": "^6.1.0", "@umijs/fabric": "^2.5.1", "@umijs/plugin-blocks": "^2.0.5", "@umijs/plugin-esbuild": "^1.0.1", "@umijs/preset-ant-design-pro": "^1.2.0", "@umijs/preset-react": "2.1.2", "carlo": "^0.9.46", "chalk": "^4.0.0", "cross-env": "^7.0.0", "cross-port-killer": "^1.1.1", "detect-installer": "^1.0.1", "eslint": "^7.1.0", "express": "^4.17.1", "mockjs": "^1.0.1-beta3", "puppeteer-core": "^8.0.0", "stylelint": "^13.0.0", "typescript": "^4.0.3" }, "engines": { "node": ">=10.0.0" }, "checkFiles": [ "src//.js", "src//.ts", "src/*/.less", "config//.js", "scripts//.js" ], "create-umi": { "ignoreScript": [ "docker", "functions", "site", "generateMock" ], "ignoreDependencies": [ "netlify", "serverless" ], "ignore": [ ".dockerignore", ".git", ".github", ".gitpod.yml", "CODE_OF_CONDUCT.md", "Dockerfile", "Dockerfile.", "lambda", "LICENSE", "netlify.toml", "README..md", "azure-pipelines.yml", "docker", "CNAME", "create-umi" ] } }
config: hash: true, antd: {}, locale: { antd: true, }, dva: { hmr: true, lazyLoad: true, }, history: { type: 'browser', },
dynamicImport: {
loading: '@/components/PageLoading/index',
},
targets: {
ie: 11,
},
// umi routes: https://umijs.org/docs/routing
routes,
// Theme for antd: https://ant.design/docs/react/customize-theme-cn
theme: {
'primary-color': defaultSettings.primaryColor,
},
title: false,
ignoreMomentLocale: true,
proxy,
manifest: {
basePath: '/',
},
// 快速刷新功能 https://umijs.org/config#fastrefresh
fastRefresh: {},
esbuild: {},
mfsu: {}
还是会出现第一次启动项目后再次启动项目 css引入的背景图找不到资源
这个问题解决了嘛,我也遇到这个问题
项目代码: link 问题说明: 使用脚手架新建了一个很简单的项目,是一个滑动切换页面的demo,运行时出现了一个很奇怪的问题: 第一次执行 yarn run start 一切正常 这个时候 ctrl+c 把项目停掉 然后再次执行yarn run start 项目重新启动起来以后 所有的图片都没有加载,这个时候重启第三次第四次结果都是一样的,一直不显示index.css 里边引用的图片 这个时候 修改一下.umirc.js 这个文件(比如增加一个空格)然后保存以后重新yarn run start 就又正常了,后续如果再ctrl+c 的话 图片又会加载不进来,以此类推
本人前端小白,刚刚接触react 的庞大技术栈,学习过程中接触到了umi,简直是新手福音,解决各种插件配置问题,快速上手开发。遇到这么个奇怪的问题,希望前辈不吝赐教!