Azure + React + ASP.NET Core 项目笔记一:项目环境搭建(二)

有意义的标题

  • [pnpm 安装](#pnpm 安装)
  • [umi4 脚手架搭建](#umi4 脚手架搭建)
  • 打包语句变更
  • [Visual Studio调试](#Visual Studio调试)
  • [Azure 设置变更](#Azure 设置变更)
  • 发布

pnpm 安装

参考官网,或者直接使用npm安装

bash 复制代码
npm install -g pnpm

umi4 脚手架搭建

我这里用的umi4,官网已附上

这里需要把clientapp清空,之后

bash 复制代码
cd ClientApp
pnpm dlx create-umi@latest

选择你需要的选项后就会自动安装

安装好之后就可以运行看看

bash 复制代码
$ pnpm dev
        ╔═════════════════════════════════════════════════════╗
        ║ App listening at:                                   ║
        ║  >   Local: https://127.0.0.1:8000                  ║
ready - ║  > Network: https://192.168.1.1:8000                ║
        ║                                                     ║
        ║ Now you can open browser with the above addresses👆 ║
        ╚═════════════════════════════════════════════════════╝
event - compiled successfully in 1121 ms (388 modules)
event - MFSU compiled successfully in 1308 ms (875 modules)

打包语句变更

npm 都改成pnpm,之前熟悉了npm的同学也可以试试pnpm

bash 复制代码
pnpm build

之后也跟之前的语句类似,打包好的文件会放在dist文件夹中

Visual Studio调试

如果想在Visual Studio中调试,记得SpaProxyServerUrl替换一下,这样就能自动跳转了

csharp 复制代码
<SpaProxyServerUrl>http://localhost:8000</SpaProxyServerUrl>

Azure 设置变更

由于我这次项目使用Azure部署,但是默认设置会有点问题,并不会显示页面,是因为路径问题

在Azure里的Web App中,进入Configuration,

Path mappings -> Virtual applications and directories修改一下

bash 复制代码
\wwwroot   => \wwwroot\dist

发布

之后就是发布啦
Visual Studio中右键dist

选择发布dist

之后在Web App中Console中也能发现dist文件夹上传了

再打开我们的domian

完美!

如果有帮助到你,能点个赞嘛!!谢谢!!!

相关推荐
donk13143 小时前
React Native for OpenHarmony 实战:三方库 react-native-step-indicator 的鸿蒙化适配指南
分布式·react native·react.js·wpf·harmonyos
donk13145 小时前
React Native for OpenHarmony 实战:三方库 react-native-segmented-control-tab 的鸿蒙化适配指南
javascript·react native·react.js·华为·harmonyos
编码者卢布6 小时前
【Azure App Service】分享App Service for Window中自动抓取Memory DUMP的方法
microsoft·azure
donk13147 小时前
React Native for OpenHarmony 实战:三方库 react-native-toast-message 的鸿蒙化适配指南
react native·react.js·音视频·harmonyos
小羊没烦恼!1 天前
如何在IIS6,7中部署ASP.NET网站?
数据库·后端·python·web安全·asp.net
看浪的路人1 天前
第2讲:ReAct 模式从零实现——不用框架,手写一个 Agent 内核
前端·react.js·前端框架
宝桥南山1 天前
.NET 11 - 尝试一下Minimal API中的异步验证新特性
microsoft·微软·c#·asp.net·.net·.netcore
一木 之林1 天前
LangChain 第6章 Agent 智能体核心:create_agent 统一入口与 ReAct 循环
前端·react.js·langchain
Lost of 程序猿1 天前
责任链模式实战:审批流里“层层把关“的艺术
后端·设计模式·asp.net·责任链模式
霸道流氓气质1 天前
在线 AI 绘图平台:Flux 模型集成、Serverless 弹性部署与 ComfyUI 工作流的 React + Spring AI 全栈实战
人工智能·react.js·serverless