应用项目规范

  • 遵循 Egg 项目开发规范,其中 app/web 目录为前端代码, config/res.config.js 为 webpack 配置文件
  • 本地开发 Webpack 内存构建,发布构建静态资源在 app/public 目录,服务端在 app/view 目录
  • TypeScript 除了基础配置文件和特殊声明的文件外,所有代码文件已 .tsx 作为后缀名, 详细情况请参考 https://github.com/easy-team/res-awesome 骨架项目规范

默认配置

  • config/res.config.jseasywebpack 构建配置文件,除 entry 外,一般无需额外配置(注意该文件为 js 文件)

  • config/tsconfig.json 为 前后端 TypeScript 基础配置,后续考虑内置 res 框架

  • tsconfig.json 为 Node 端 TypeScript 基础配置,集成 config/tsconfig.json , 后续考虑内置 res 框架

  • app/web/tsconfig.json 为前端 TypeScript 基础配置,集成 config/tsconfig.json 后续考虑内置 res 框架

约束说明

  • 前端渲染时,res ssr 默认 layout 为 node_modules/res/app/web/view/layout.html可以通过如下方式覆盖配置。无特殊要求,无需配置。
//${root}/config/config.default.js
exports.reactssr = {
  layout: path.join(app.baseDir, 'app/web/view/layout.html'),
};
  • 本地开发时,Webpack 编译文件在内存,res build 时落地磁盘。Node 端运行文件存放到 app/view 目录,前端构建文件存放到 app/public 目录。框架已内置处理,无需关心。
  • TypeScript 构建会在各目录生成 ts 对应的 js 文件,js 文件是被 Git 忽略的,同时需要配置 vscode 隐藏 js 文件
{
 "files.exclude": {
    "**/*.js": {
      "when": "$(basename).ts"
    }
  }
}

Author: sky
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source sky !
 Previous
服务端渲染(SSR) 服务端渲染(SSR)
Node 代码实现/egg-react/node在 Node 服务端运行 jsbundle,并渲染成完整的 HTML 内容返回给客户端使用 ctx.render 进行 React 服务端渲染,文件名为 Webpack entry 文...
2020-05-31 sky
Next 
Webpack 4 编译内存泄漏 Webpack 4 编译内存泄漏
增加内存堆栈大小(只能缓解,不能根除)
2020-04-18 sky