react 根据不同的入口文件build

配置环境变量
REACT_APP_BUILD =  "HelloWorld"
// entrypoints/hello-world
import React from 'react';
import HelloWorldCom from '../view/components/hello-world'

const HelloWorld =()=>{
    return <HelloWorldCom/>
}
export default HelloWorld;
function bootstrap() {
  switch(process.env.REACT_APP_BUILD) {
    case "HelloWorld": return import("./entrypoints/hello-world"); 
    default: return import("./entrypoints/wmb-openness") 
  }
}

export default bootstrap
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import reportWebVitals from './reportWebVitals';
import {BrowserRouter} from 'react-router-dom'
import Routes from './route/route';
import bootstrap from "./bootstrap";

bootstrap().then(({ default: App }) => ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
));
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容