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

完美!

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

相关推荐
lymboy5 小时前
Spring AI的工具调用循环,本质就是ReAct:一次源码级拆解
人工智能·spring·react.js
Darling噜啦啦18 小时前
React 组件化实战:从 TodoList 吃透父子通信与状态管理
react.js
bloglin999991 天前
langchain 和 langgraph 和 react
javascript·react.js·langchain
触底反弹1 天前
🚀 删了数据刷新又回来?3 组件 × 4 回调 × 3 坑讲透 React 父子通信
前端·javascript·react.js
sugar__salt1 天前
useState 深入浅出:React 状态管理的基石
前端·react.js·前端框架
moMo1 天前
状态管理第一步:React useState 核心行为完全拆解
react.js
拾年2751 天前
React 组件通信完全指南 —— 从 Todo App 搞懂父子组件那点事
react.js
先吃饱再说1 天前
React 组件通信:从 Props 单向传递到自定义事件
前端·react.js·前端框架
何时梦醒1 天前
⚛️ React 19 组件化实战 —— 从零搭建 Todo List 并吃透组件通信
前端·人工智能·react.js