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

现象描述

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$ 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 强制文件名大小写匹配的插件
1
yarn add case-sensitive-paths-webpack-plugin --dev
  1. 添加配置config/plugin.config.js
1
2
3
4
5
6
7
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';

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

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :