How can I use multiple entries in Webpack alongside multiple HTML files in HtmlWebpackPlugin?

前端 未结 2 1863
你的背包
你的背包 2021-01-14 23:07

We\'d like to have two outputs from Webpack - our entire app with all of its dependencies, and a single different page with only one dependency (that isn\'t shared by the ma

2条回答
  •  盖世英雄少女心
    2021-01-14 23:41

    When you set:

    module.exports = {
      //...
      optimization: {
        runtimeChunk: true
      }
    };
    

    It generates a runtime chunk. What is a runtime? Runtime is where ALL the code that webpack uses to load other files are. This is the heart of webpack when you run build.

    Since you have 2 separate bundle files: resetPassword and app.

    Ok, you have all the files you need. You maybe need vendors on both too, since vendor in your case contains everything from node_modules. So basically you will have:

    html 1: app, vendor, runtimeChunk.

    html 2: reset_password, vendor, runtimeChunk.

    By doing that, you application should run.

提交回复
热议问题