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

完美!

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

相关推荐
To_OC4 小时前
踩了个 TS 的坑之后,我终于把 type 和 interface 掰明白了
前端·react.js·typescript
Eloudy11 小时前
ReAct 原理简介
前端·javascript·人工智能·react.js·agent·gpu
嘟嘟071712 小时前
Next.js 博客左侧笔记列表是怎么从 Redis 渲染出来的?从组件、children 到动态路由一次讲清
redis·react.js·前端工程化
张元清14 小时前
React useInterval Hook:没有过期闭包的 setInterval (2026)
javascript·react.js
MXN_小南学前端14 小时前
React超长文本域中实现“返回顶部”浮动按钮
前端·javascript·react.js
YIAN19 小时前
http无状态?State来展示!从基础路由到鉴权守卫,吃透 SPA 前端路由核心
前端·react.js
console.log('npc')20 小时前
React 19 + Vite 企业级前端项目:从零搭建到规范交付
前端·react.js·前端框架
光影少年21 小时前
react离线缓存、图片缓存方案
开发语言·前端·javascript·react native·react.js·缓存·前端框架
抱抱宝1 天前
Agent-study项目教程(03):手写 Mini-ReAct Agent(不依赖框架)
javascript·人工智能·gpt·react.js·prompt·agent
想要成为糕糕手1 天前
🚀 在浏览器里跑 DeepSeek-R1?WebGPU 端侧推理实战(六)—— 完结篇:消息渲染与流式收尾
react.js·typescript·llm