Different main entry point in package.json for node and browser

后端 未结 4 1867
我在风中等你
我在风中等你 2021-02-20 16:02

In isomorphic react app I have myModule which should behave differently on node and browser environments. I would like configure this split point i

4条回答
  •  佛祖请我去吃肉
    2021-02-20 16:18

    To have a different entry point for client and server in a Node Module, you can use process.browser flag and handle the same

    if (process.browser) {
      // load client entry point
    } else {
      // load server entry point
    }
    

提交回复
热议问题