ys-cli-react
v1.0.52
Published
* 支持 [qiankun](https://qiankun.umijs.org/zh/guide/getting-started) 生成主应用和子应用 * 支持 [vite](https://vitejs.cn/guide/) 和 [webpack](https://webpack.docschina.org/guides/) 配置
Downloads
22
Readme
可生成以下配置项目
安装
一、Install with npm:
npx ys-cli-react yourProjectName
二、run with npm
cd yourProjectName
npm run start:open
三、启用离线应用Workbox(仅webpack支持)
1.webpack.config.js 添加 useWorkbox配置
module.exports = {
useWorkbox: true
}
2.入口js文件添加如下代码
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./service-worker.js').then(registration => {
console.log('SW registered: ', registration);
}).catch(registrationError => {
console.log('SW registration failed: ', registrationError);
});
});
}
四、主应用修改src/index.js (微应用需注意以下配置)
registerMicroApps([
{
name: 'react-webpack2', // 微应用package.json name字段名保持一致
entry: '//localhost:8090', // 端口号和微应用保持一致
container: '#container',
activeRule: '/courses',
}
]);