问题:项目中使用了 Umi3,尝试从 umi
中引入 useLocation
并在组件中使用后,发现,在开发环境中,会自动引入 webpack:///./node_modules/antd/es/style/index.less
,同一代码在生产环境中,是不会引入的,存在样式差异。
困惑:不确定这是 feature 还是 bug,或者是本人使用方式不对,求解惑,很喜欢 Umi,非常感谢。
请使用
yarn create @umijs/umi-app
创建,并上传到你的 GitHub 仓库
https://github.com/JophielZX/umi3-demo
-
使用
yarn create @umijs/umi-app
初始化项目 -
修改
src/pages/index.tsx
文件,如下:import React from 'react'; import { useLocation } from 'umi'; import styles from './index.less'; export default () => { const { pathname } = useLocation(); return ( <div> <h1 className={styles.title}>Page index</h1> <div>pathname: {pathname}</div> </div> ); };
-
执行
yarn start
查看开发环境样式 -
执行
yarn build
,而后serve dist
,查看生产环境样式
- Yarn 版本:1.22.4
- Umi 版本:3.0.11
- Node 版本:v12.16.1
- 操作系统:Win10