美文网首页
react 根据不同的入口文件build

react 根据不同的入口文件build

作者: 呆桃冲鸭冲鸭 | 来源:发表于2021-11-18 14:45 被阅读0次
    配置环境变量
    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();
    

    相关文章

      网友评论

          本文标题:react 根据不同的入口文件build

          本文链接:https://www.haomeiwen.com/subject/uhgdtrtx.html