{"id":21240043,"url":"https://github.com/open-hand/choerodon-front-boot","last_synced_at":"2025-07-10T19:32:42.720Z","repository":{"id":38376725,"uuid":"134035443","full_name":"open-hand/choerodon-front-boot","owner":"open-hand","description":"Choerodon front boot is a toolkit about front end package management, startup, compilation. It is mainly used to provide custom some configurations file to create a project of React that can be modified to some extent.","archived":false,"fork":false,"pushed_at":"2023-07-19T14:02:14.000Z","size":4397,"stargazers_count":27,"open_issues_count":12,"forks_count":28,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-09T03:45:07.633Z","etag":null,"topics":["choerodon","css","gulp","html","javascript","react","webpack"],"latest_commit_sha":null,"homepage":"https://choerodon.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-hand.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-19T06:14:39.000Z","updated_at":"2023-08-14T02:23:27.000Z","dependencies_parsed_at":"2024-06-19T01:30:25.654Z","dependency_job_id":"b2cb1936-b376-40e0-8413-626aa3aec197","html_url":"https://github.com/open-hand/choerodon-front-boot","commit_stats":null,"previous_names":["choerodon/choerodon-front-boot"],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/open-hand/choerodon-front-boot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-hand%2Fchoerodon-front-boot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-hand%2Fchoerodon-front-boot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-hand%2Fchoerodon-front-boot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-hand%2Fchoerodon-front-boot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-hand","download_url":"https://codeload.github.com/open-hand/choerodon-front-boot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-hand%2Fchoerodon-front-boot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264639923,"owners_count":23642319,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["choerodon","css","gulp","html","javascript","react","webpack"],"created_at":"2024-11-21T00:47:35.641Z","updated_at":"2025-07-10T19:32:42.353Z","avatar_url":"https://github.com/open-hand.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 主要功能\n\n `@choerodon/boot`为猪齿鱼前端提供了模块的启动/打包，以及子模块的组合功能。\n\n## 使用\n\n### 1. 安装依赖\n\n```\nyarn add @choerodon/boot\n```\n\n### 2. 创建配置文件\n\n在项目目录/react目录下创建`config.js`\n\n```\nmodule.exports = {\n  modules: [\n    '.',\n  ]\n};\n```\n\n### 3. 添加命令\n\n在package.json添加\n\n```json\n\"scripts\": {\n    \"start\": \"node --max_old_space_size=4096 node_modules/@choerodon/boot/bin/choerodon-front-boot-start --config ./react/config.js\",\n    \"dist\": \"choerodon-front-boot dist --config ./react/config.js\"    \n  },\n```\n\n## 常用运行配置及配置项说明\n\n| 名称          | 值类型                                | 用途                                    | 默认值                                         |\n| ------------- | ------------------------------------- | --------------------------------------- | ---------------------------------------------- |\n| port          | number                                | 前端启动时的端口                        | 9090                                           |\n| modules       | Array\u003cstring\u003e                         | 指定启动的子模块，其中`.`指代自身子模块 |                                                |\n| webpackConfig | (config:webpackConfig)=\u003ewebpackConfig | 自定义webpack配置                       |                                                |\n| entry         | string                                | 应用入口文件                            | node_modules下的@choerodon/master/lib/entry.js |\n| theme         | Object                                | 全局覆盖less变量                        | {}                                             |\n| titlename     | string                                | html的title                             | Choerodon \\| 多云应用技术集成平台              |\n\n\u003e 更多配置请查看[链接](https://code.choerodon.com.cn/hzero-c7ncd/choerodon-front-boot/blob/master/react/config/getChoerodonConfig.js)\n\u003e\n\n\n\n## 子模块路由收集\n\n### 1. 配置方式\n\n猪齿鱼前端具有子模块组合功能，猪齿鱼前端可分为`分前端`和`总前端`，分前端指代各个子模块，这些子模块在启动时一般会启动自身，这时需要配置`modules`为`['.']`，总前端是子模块的聚合，`modules`配置为子模块的名称列表，如：\n\n```javascript\nconst config = {\n  local: true, //是否为本地开发\n  modules: [\n    '@choerodon/base',\n    '@choerodon/asgard',\n    '@choerodon/notify',\n    '@choerodon/manager',\n    \"@choerodon/agile\",\n    \"@choerodon/testmanager\",\n    \"@choerodon/knowledge\",\n    \"@choerodon/devops\",\n    \"@choerodon/code-repo\",\n    \"@choerodon/prod-repo\",\n  ]\n};\n\nmodule.exports = config;\n```\n\n### 2. 约定\n\n猪齿鱼前端子模块应遵守以下约定\n\n1. 在package.json中配置唯一的`routeName`和`main`和`install`（可选）字段\n2. main指定了一个文件路径，这个文件应有一个默认导出\n\n### 3. 路由分配\n\n每个在modules中配置的子模块都会被分配一个一级路由，路由分配规则是读取子模块的`package.json`中的`routeName`字段，并引入`main`字段配置的文件，所以请保证不同的子模块配置了不同的`routeName`。\n\n例如针对以下`package.json`配置：\n\n```json\n{\n  \"routeName\": \"agile\",\n  \"main\": \"./lib/index.js\",\n}\n```\n\n会生成\n\n```javascript\nconst agile = React.lazy(()=\u003eimport(\"D:\\\\Desktop\\\\分前端\\\\agile-service\\\\react\\\\index.js\"));\n\n...\n\u003cRoute path=\"/agile\" component={agile}/\u003e\n```\n\n\n\n## 环境变量方案\n\nChoerodon猪齿鱼平台的前端环境变量方案是一种给用户自定义环境变量，并且可以在部署时进行替换的一种方案。\n\n### 1. 使用\n\n在react目录下建立.env文件，以`键=值`的方式写入环境变量，最终可以使用`window._env_`来访问配置的环境变量。\n\n### 2. 常用环境变量\n\n| 名称             | 类型                                                         | 用途                                   |\n| ---------------- | ------------------------------------------------------------ | -------------------------------------- |\n| HTTP             | 'http'\\|'https'                                              | 目前没什么用（已废弃）                 |\n| API_HOST         | string                                                       | 指定后端api地址前缀                    |\n| CLIENT_ID        | string                                                       | 指定登录时使用的客户端                 |\n| LOCAL            | true\\|false                                                  | 是否为本地开发（目前请始终设置为true） |\n| WEBSOCKET_SERVER | string                                                       | 指定后端websocket地址前缀              |\n| outward          | 逗号隔开的路由地址，如/agile/preview,/agile/test,/agile/outside | 指定不需要登录即可访问的页面           |\n\n### 3. 运行原理\n\n环境变量方案分为开发时和部署时\n\n在开发模式下使用了[dotenv-runtime-plugin](https://github.com/laincarl/dotenv-runtime-plugin)来实现了开发时的环境变量热更新。\n\n在部署时，会执行[env.sh](https://code.choerodon.com.cn/hzero-c7ncd/choerodon-front-boot/blob/master/env.sh)实现在docker启动时读取docker配置的环境变量，并生成一个js语句，插入到html中\n\n## 跨模块组件注入方案\n\n[链接](https://code.choerodon.com.cn/hzero-c7ncd/c7n-front/blob/master/packages/inject/README.md)\n\n## 组件转发\n\n由于历史原因，你可以使用`import ...  from '@choerodon/boot'`形式的语句来引用`@choerodon/master`中的内容，这是因为`@choerodon/boot`配置了`alias`\n\n\u003e 新代码请使用`import ... from @choerodon/master`，因为`alias`之后可能会去掉。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-hand%2Fchoerodon-front-boot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-hand%2Fchoerodon-front-boot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-hand%2Fchoerodon-front-boot/lists"}