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

后端 未结 8 1480
天命终不由人
天命终不由人 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

    0 讨论(0)
  • 2020-12-12 13:15

    what really solved it for me was this:

    entry:  {
        app : __dirname + "/app/views/app/app.js",
        admin : __dirname + "/app/views/admin/admin.js"
    }
    
    output: {
        path: __dirname + "/public",
        filename: "[name].js"
    },
    
    0 讨论(0)
提交回复
热议问题