Exclude react from webpack bundle

后端 未结 3 1297
终归单人心
终归单人心 2020-12-14 06:33

I\'m trying to exclude react from my bundle which is generated by webpack. Reason being, we have a global version of react available on the page so I\'ll be using that.

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 06:52

    You can just create multiple entries to separate react from your application bundle. You can for example do the following, using the webpack CommonsChunkPlugin :

    module.exports = {
    entry: {
        "app": "your app entry file",
        "react" : "react"
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin("react", "react.bundle.js")
       ]
    }
    

提交回复
热议问题