On the question of webpack packaging, how to package into multiple folders, each folder has the corresponding html,js and css?

for projects created with vue-cli, the default webpack configuration is packaged into a single file. Now there is a need to package out many folders. The corresponding html,js and css in different folders have modified some configurations to be in the form of multiple chunk. Html has been typed into the folder separately, but js and css are still in the same folder. How to configure them?

entry: {
    app: "./src/main.js",
    one: "./src/main.1.js"
},
// Template for index.html
    index: path.resolve(__dirname, "../dist/app/index.html"),
    one: path.resolve(__dirname, "../dist/one/index.html"),
new HtmlWebpackPlugin({
  filename: config.build.index,
  template: "index.html",
  inject: true,
  minify: {
    removeComments: true,
    collapseWhitespace: true,
    removeAttributeQuotes: true
    // more options:
    // https://github.com/kangax/html-minifier-sharpoptions-quick-reference
  },
  // necessary to consistently work with multiple chunks via CommonsChunkPlugin
  chunksSortMode: "dependency"
}),
new HtmlWebpackPlugin({
  filename: config.build.one,
  template: "index.html",
  inject: true,
  minify: {
    removeComments: true,
    collapseWhitespace: true,
    removeAttributeQuotes: true
    // more options:
    // https://github.com/kangax/html-minifier-sharpoptions-quick-reference
  },
  // necessary to consistently work with multiple chunks via CommonsChunkPlugin
  chunksSortMode: "dependency"
}),

above is the configuration I added

the following is the packaged folder structure

![] [3]

css and js are in static. How to configure them if you want to put them in the app and one folders respectively?

Feb.27,2021

you can directly use name of entry as the entry:

  

how to package multiple folders with webpack4

Menu