Front-end Deploy Agent
- 准备好docker和docker-compose环境
- 把项目拷贝到~/feda目录
- 把你自己的https私钥private-key.pem和证书cert.pem放在~/.ssh目录下
- 进入~/feda, 执行
docker-compose up -d
Method: POST
Url: /rest/feda/v1/apps/:appName
Query: null
Body:
{
package: zip包文件
}
Response:
// success:
{
success: true
}
// failed:
{
success: false,
message: '...' // 错误信息
}
Method: POST
Url: /rest/feda/v1/apps
Query: null
Response:
// success:
{
success: true,
data: ['app1@version1', 'app2@version2']
}
// failed:
{
success: false,
data: 'Error' // 错误信息
}
Method: GET
Url: /feda-assets/:appName/omicro.config.json
Response:
{
"name": "normal-app@1.0.0",
"assets": {
"css": [
"entry.1ffa7be5.css"
],
"js": [
"vendors.8f02d439.js",
"entry.8f02d439.js"
]
}
}
部署在Feda上的所有前端微服务,其静态资源路径由https://{host}/feda-assets/{serviceName}/omicro.config.json
声明,因此,对应的obvious中间件实现为:
const obviousFedaMiddleware = async (name, loadJs, loadCss) => {
const res = await fetch(`https://{host}/feda-assets/${name}/omicro.config.json`);
const data = await res.json();
for(const cssSrc of data.assets.css) {
await loadCss(cssSrc);
}
for(const jsSrc of data.assets.js) {
await loadJs(jsSrc);
}
}
创建bus后即可根据服务名拉起所有部署在Feda上的前端微服务:
import {createBus, getBus} from '@runnan/obvious';
createBus('fedaBus', null , obviousFedaMiddleWare);
const bus = getBus('fedaBus');
bus.startApp('normal-app@1.0.0');
- obvious:轻量级的微前端框架
- react-obvious: 结合react和obvious的类react-redux框架
- omicro-cli: obvious微前端项目脚手架,支持生成代码模板和把项目部署到Feda