https://blog.csdn.net/qq_34829447/article/details/81677198
部署方法:
使用npm run build将项目打包
把打包后的文件夹中内容放到tomcat中webapps下的Root中
开启服务器访问localhost:8080端口即可以看到你的项目内容
不放置在Root目录下的坑:
由于默认path.js【路径:你的react项目名\node_modules\react-scripts\config\path.js】的配置是’/’即对根目录有效,所以如果不放在root下则需要将’/’变成’./’即相对路径有效。(修改代码约在第45行)
function getServedPath(appPackageJson) {
const publicUrl = getPublicUrl(appPackageJson);
const servedUrl =
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : './');//this line
return ensureSlash(servedUrl, true);
}
作者:汪喆_Jack
来源:CSDN
原文:https://blog.csdn.net/qq_34829447/article/details/81677198
版权声明:本文为博主原创文章,转载请附上博文链接!
网友评论