Conditional build based on environment using Webpack

前端 未结 9 665
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 21:40

I have some things for development - e.g mocks which I would like to not bloat my distributed build file with.

In RequireJS you can pass a config in a plugin file an

9条回答
  •  爱一瞬间的悲伤
    2020-11-30 22:24

    While this is not the best solution, it may work for some of your needs. If you want to run different code in node and browser using this worked for me:

    if (typeof window !== 'undefined') 
        return
    }
    //run node only code now
    

提交回复
热议问题