Linux下部署ant-design-pro大小写敏感问题

现象描述

在Mac和Win上打包没问题,放到Centos下打包报错:

$ yarn build
yarn run v1.19.1
$ umi build

✖ Webpack
  Compiled with some errors in 1.05m

 ERROR  Failed to compile with 1 errors                                                                                                                                                               11:06:50 AM

This relative module was not found:

* ../User/resetPwd in ./src/pages/.umi-production/router.js

 ERROR CODE  ERR_WEBPACK_MODULE_NOT_FOUND

 DETAILS

## Possible Reasons

    1. The file does not exist
    2. Case problem

If the build under mac is successful and the build fails under linux or on the cloud build platform, it must be case problem.

## Solution

If it is a case, please double check that the import or require file and the target file are in the same case.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

问题解决

文件引用大小写问题

参考:https://github.com/ant-design/ant-design-pro/issues/2267

case-sensitive-paths 插件检测路径大小写问题

  1. 添加 webpack 强制文件名大小写匹配的插件
yarn add case-sensitive-paths-webpack-plugin --dev
  1. 添加配置config/plugin.config.js
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';

config.plugin('case-sensitive-paths').use(CaseSensitivePathsPlugin, [
  {
    debug: true,
  },
])
  1. 启动开发服务,插件会检查文件名大小写并给出错误提醒
yarn start

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/18/case-sensitive-issue-in-deploying-ant-design-pro-under-linux/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Linux下部署ant-design-pro大小写敏感问题
现象描述 在Mac和Win上打包没问题,放到Centos下打包报错: $ yarn build yarn run v1.19.1 $ umi build ✖ Webpack Compiled with some errors in 1.05m ……
<<上一篇
下一篇>>
文章目录
关闭
目 录