How to set multiple file entry and output in project with webpack?

后端 未结 8 1489
天命终不由人
天命终不由人 2020-12-12 12:14

How to set multiple file entry/output in project with webpack?

I follow http://webpack.github.io/docs/tutorials/getting-started/ success compile if only one file in

8条回答
  •  粉色の甜心
    2020-12-12 13:15

    For many entry points use arrays as a value of entry property:

    entry: {
      app: ['./app/main.js', '.lib/index.js'],
      vendors: ['react']
    }
    

    app and vendors are arrays, so you can put there as many file paths as you need.

    For output case:

    output: {
      path: staticPath,
      filename: '[name].js'
    }
    

    The [name] is taken from entry properties, so if we have app and vendors as properties, we got 2 output files - app.js and vendors.js.

    Documentation link

提交回复
热议问题