{"_id":"@arkxio/choerodon-boot","_rev":"2-ed183ba82c25056a6ebf0c2913f50643","name":"@arkxio/choerodon-boot","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.1":{"name":"@arkxio/choerodon-boot","version":"1.2.1","keywords":["choerodon","c7n","boot","framework","frontend"],"license":"ISC","_id":"@arkxio/choerodon-boot@1.2.1","maintainers":[{"name":"arkxio","email":"arkxio@qq.com"}],"homepage":"http://choerodon.io/","bugs":{"url":"https://github.com/choerodon/choerodon/issues"},"bin":{"choerodon-front-boot":"bin/choerodon-front-boot"},"dist":{"shasum":"c141952c24da1bdce6508299084702e0d271d1ac","tarball":"https://registry.npmjs.org/@arkxio/choerodon-boot/-/choerodon-boot-1.2.1.tgz","fileCount":49,"integrity":"sha512-c+WjF5Gfj5AsxGN+thP30O5vG7Mqx2OGftu/Vq19DRNvH4bqIv4Gsx62HRDJEQ1jxzMJ95v80gEMMkTiE8s/nA==","signatures":[{"sig":"MEUCICbFSuHBz8gdACgwwE9Hq2U+JQHcFATmTCLgK4w6jUm7AiEAoY5CsdYuHIRNhkeJRUCca6HZQJ8xLpHHPcYqYfHQzYY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":159772},"main":"lib/index.js","types":"./lib/index.d.ts","gitHead":"441c24d79d29a3eb48e225f8e4a8bc6603c040d0","scripts":{"lint":"npm run lint:es && npm run lint:style","clean":"rimraf lib","start":"node ./test/start --config ./choerodon.config.js","watch":"compiler compile --watch","compile":"compiler compile","lint:es":"eslint react/**/*.{js,jsx} test ./choerodon.config.js","dist:bin":"node ./bin/choerodon-front-boot dist --config ./choerodon.config.js","lint:fix":"eslint react/**/*.{js,jsx} --fix","start:bin":"node ./bin/choerodon-front-boot start --config ./choerodon.config.js","lint:style":"stylelint react/**/*.less","compile:bin":"node ./bin/choerodon-front-boot compile","lint-staged":"lint-staged","postpublish":"npm run clean","prebuild:bin":"npm run compile","prestart:bin":"npm run compile","lint-staged:es":"eslint test ./choerodon.config.js","prepublishOnly":"npm run compile"},"_npmUser":{"name":"arkxio","actor":{"name":"arkxio","type":"user","email":"arkxio@qq.com"},"email":"arkxio@qq.com"},"repository":{"url":"git+https://github.com/choerodon/choerodon-front-boot.git","type":"git"},"_npmVersion":"10.2.4","description":"Choerodon Scaffold to run react application.","directories":{},"_nodeVersion":"18.19.1","dependencies":{"gaze":"^1.1.3","less":"^3.11.1","open":"^7.0.2","sass":"^1.26.10","chalk":"2.4.2","husky":"^1.1.1","mkdirp":"^0.5.1","moment":"^2.29.1","pkg-up":"3.1.0","rimraf":"2.4.3","address":"1.1.2","is-root":"2.1.0","warning":"^3.0.0","webpack":"^4.42.0","fs-extra":"^7.0.0","inquirer":"7.2.0","commander":"^2.9.0","minimatch":"^10.0.3","stylelint":"^8.4.0","@babel/cli":"^7.8.4","css-loader":"^3.4.2","prop-types":"^15.5.10","strip-ansi":"6.0.0","text-table":"0.2.0","url-loader":"^3.0.0","webpackbar":"^4.0.0","cross-spawn":"^6.0.5","file-loader":"^5.1.0","less-loader":"^5.0.0","lint-staged":"^7.2.2","sass-loader":"^9.0.3","shell-quote":"1.7.2","webpack-cli":"^3.3.11","autoprefixer":"^6.7.7","babel-loader":"^8.0.6","browserslist":"4.12.0","loader-utils":"2.0.0","style-loader":"^1.1.3","react-refresh":"^0.9.0","@types/webpack":"^4.41.24","postcss-loader":"^3.0.0","detect-port-alt":"1.1.6","recursive-readdir":"2.2.2","svg-sprite-loader":"^5.2.1","webpack-dev-server":"^3.10.3","html-webpack-plugin":"^3.2.0","react-error-overlay":"^6.0.7","escape-string-regexp":"2.0.0","dotenv-runtime-plugin":"^0.0.1","string-replace-loader":"^2.3.0","preload-webpack-plugin":"^3.0.0-beta.4","mini-css-extract-plugin":"^0.9.0","webpack-bundle-analyzer":"^4.5.0","stylelint-config-standard":"^18.0.0","webpack-theme-color-replacer":"1.3.18","fork-ts-checker-webpack-plugin":"4.1.6","friendly-errors-webpack-plugin":"^1.7.0","webpack-filter-warnings-plugin":"^1.2.1","case-sensitive-paths-webpack-plugin":"^2.1.2","@pmmmwh/react-refresh-webpack-plugin":"^0.4.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^7.6.0","typescript":"^5.8.3","@types/node":"^24.0.12","babel-eslint":"^10.1.0","undici-types":"^5.26.5","gulp-typescript":"^6.0.0-alpha.1","@types/minimatch":"^6.0.0","babel-preset-c7n":"^0.0.1","@choerodon/compiler":"^0.0.2","eslint-plugin-react":"^7.20.5","eslint-config-airbnb":"^18.2.0","eslint-plugin-import":"^2.22.0","eslint-config-c7n-app":"^0.0.1","eslint-plugin-jsx-a11y":"^6.3.1","@typescript-eslint/parser":"^4.0.1","eslint-plugin-react-hooks":"^4.0.8","@typescript-eslint/eslint-plugin":"^4.0.1"},"_npmOperationalInternal":{"tmp":"tmp/choerodon-boot_1.2.1_1752032572779_0.414048771723742","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-07-09T03:42:52.681Z","modified":"2026-01-08T09:17:27.100Z","1.2.1":"2025-07-09T03:42:52.977Z"},"bugs":{"url":"https://github.com/choerodon/choerodon/issues"},"license":"ISC","homepage":"http://choerodon.io/","keywords":["choerodon","c7n","boot","framework","frontend"],"repository":{"url":"git+https://github.com/choerodon/choerodon-front-boot.git","type":"git"},"description":"Choerodon Scaffold to run react application.","maintainers":[{"email":"arkxio@qq.com","name":"arkxboot"}],"readme":"# 主要功能\r\n\r\n `@choerodon/boot`为猪齿鱼前端提供了模块的启动/打包，以及子模块的组合功能。\r\n\r\n## 使用\r\n\r\n### 1. 安装依赖\r\n\r\n```\r\nyarn add @choerodon/boot\r\n```\r\n\r\n### 2. 创建配置文件\r\n\r\n在项目目录/react目录下创建`config.js`\r\n\r\n```\r\nmodule.exports = {\r\n  modules: [\r\n    '.',\r\n  ]\r\n};\r\n```\r\n\r\n### 3. 添加命令\r\n\r\n在package.json添加\r\n\r\n```json\r\n\"scripts\": {\r\n    \"start\": \"node --max_old_space_size=4096 node_modules/@choerodon/boot/bin/choerodon-front-boot-start --config ./react/config.js\",\r\n    \"dist\": \"choerodon-front-boot dist --config ./react/config.js\"    \r\n  },\r\n```\r\n\r\n## 常用运行配置及配置项说明\r\n\r\n| 名称          | 值类型                                | 用途                                    | 默认值                                         |\r\n| ------------- | ------------------------------------- | --------------------------------------- | ---------------------------------------------- |\r\n| port          | number                                | 前端启动时的端口                        | 9090                                           |\r\n| modules       | Array<string>                         | 指定启动的子模块，其中`.`指代自身子模块 |                                                |\r\n| webpackConfig | (config:webpackConfig)=>webpackConfig | 自定义webpack配置                       |                                                |\r\n| entry         | string                                | 应用入口文件                            | node_modules下的@choerodon/master/lib/entry.js |\r\n| theme         | Object                                | 全局覆盖less变量                        | {}                                             |\r\n| titlename     | string                                | html的title                             | Choerodon \\| 多云应用技术集成平台              |\r\n\r\n> 更多配置请查看[链接](https://code.choerodon.com.cn/hzero-c7ncd/choerodon-front-boot/blob/master/react/config/getChoerodonConfig.js)\r\n>\r\n\r\n\r\n\r\n## 子模块路由收集\r\n\r\n### 1. 配置方式\r\n\r\n猪齿鱼前端具有子模块组合功能，猪齿鱼前端可分为`分前端`和`总前端`，分前端指代各个子模块，这些子模块在启动时一般会启动自身，这时需要配置`modules`为`['.']`，总前端是子模块的聚合，`modules`配置为子模块的名称列表，如：\r\n\r\n```javascript\r\nconst config = {\r\n  local: true, //是否为本地开发\r\n  modules: [\r\n    '@choerodon/base',\r\n    '@choerodon/asgard',\r\n    '@choerodon/notify',\r\n    '@choerodon/manager',\r\n    \"@choerodon/agile\",\r\n    \"@choerodon/testmanager\",\r\n    \"@choerodon/knowledge\",\r\n    \"@choerodon/devops\",\r\n    \"@choerodon/code-repo\",\r\n    \"@choerodon/prod-repo\",\r\n  ]\r\n};\r\n\r\nmodule.exports = config;\r\n```\r\n\r\n### 2. 约定\r\n\r\n猪齿鱼前端子模块应遵守以下约定\r\n\r\n1. 在package.json中配置唯一的`routeName`和`main`和`install`（可选）字段\r\n2. main指定了一个文件路径，这个文件应有一个默认导出\r\n\r\n### 3. 路由分配\r\n\r\n每个在modules中配置的子模块都会被分配一个一级路由，路由分配规则是读取子模块的`package.json`中的`routeName`字段，并引入`main`字段配置的文件，所以请保证不同的子模块配置了不同的`routeName`。\r\n\r\n例如针对以下`package.json`配置：\r\n\r\n```json\r\n{\r\n  \"routeName\": \"agile\",\r\n  \"main\": \"./lib/index.js\",\r\n}\r\n```\r\n\r\n会生成\r\n\r\n```javascript\r\nconst agile = React.lazy(()=>import(\"D:\\\\Desktop\\\\分前端\\\\agile-service\\\\react\\\\index.js\"));\r\n\r\n...\r\n<Route path=\"/agile\" component={agile}/>\r\n```\r\n\r\n\r\n\r\n## 环境变量方案\r\n\r\nChoerodon猪齿鱼平台的前端环境变量方案是一种给用户自定义环境变量，并且可以在部署时进行替换的一种方案。\r\n\r\n### 1. 使用\r\n\r\n在react目录下建立.env文件，以`键=值`的方式写入环境变量，最终可以使用`window._env_`来访问配置的环境变量。\r\n\r\n### 2. 常用环境变量\r\n\r\n| 名称             | 类型                                                         | 用途                                   |\r\n| ---------------- | ------------------------------------------------------------ | -------------------------------------- |\r\n| HTTP             | 'http'\\|'https'                                              | 目前没什么用（已废弃）                 |\r\n| API_HOST         | string                                                       | 指定后端api地址前缀                    |\r\n| CLIENT_ID        | string                                                       | 指定登录时使用的客户端                 |\r\n| LOCAL            | true\\|false                                                  | 是否为本地开发（目前请始终设置为true） |\r\n| WEBSOCKET_SERVER | string                                                       | 指定后端websocket地址前缀              |\r\n| outward          | 逗号隔开的路由地址，如/agile/preview,/agile/test,/agile/outside | 指定不需要登录即可访问的页面           |\r\n\r\n### 3. 运行原理\r\n\r\n环境变量方案分为开发时和部署时\r\n\r\n在开发模式下使用了[dotenv-runtime-plugin](https://github.com/laincarl/dotenv-runtime-plugin)来实现了开发时的环境变量热更新。\r\n\r\n在部署时，会执行[env.sh](https://code.choerodon.com.cn/hzero-c7ncd/choerodon-front-boot/blob/master/env.sh)实现在docker启动时读取docker配置的环境变量，并生成一个js语句，插入到html中\r\n\r\n## 跨模块组件注入方案\r\n\r\n[链接](https://code.choerodon.com.cn/hzero-c7ncd/c7n-front/blob/master/packages/inject/README.md)\r\n\r\n## 组件转发\r\n\r\n由于历史原因，你可以使用`import ...  from '@choerodon/boot'`形式的语句来引用`@choerodon/master`中的内容，这是因为`@choerodon/boot`配置了`alias`\r\n\r\n> 新代码请使用`import ... from @choerodon/master`，因为`alias`之后可能会去掉。\r\n\r\n","readmeFilename":"README.md"}