webpackminifywebpack-2uglifyjswebpack-5

How to add multiple sources and multiple outputs for WebPack minify


I am trying to minify file like this from file1 -> minified file1 file2 -> minified file2. Please post if there is a way to achieve that.

const path = require("path");

module.exports = {
entry: "./modules/users/client/controllers/admin/user.client.controller.js",
output: {
    path: path.resolve(__dirname,'modules/users/client/controllers/admin'),
    filename: "user.client.controller.js"
},
optimization: {
  minimize: true
}
};

module.exports = {
    entry: "./modules/users/client/controllers/admin/register-user.client.controller.js",
    output: {
        path: path.resolve(__dirname,'modules/users/client/controllers/admin'),
        filename: "register-user.client.controller.js"
    },
    optimization: {
      minimize: true
    }
    };

Solution

  • This solved my question

    const path = require("path");
    
    module.exports = {
    entry: {
      'users/client/controllers/admin/viewownerclientcontroller':['./modules/users/client/controllers/admin/viewownerclientcontroller.js']
    
    
    
    },
    output: {
      path: path.resolve(__dirname, 'modules'),
      filename:  '[name].js'
    },
    
    optimization: {
    minimize: true
    }
    };