const path = require('path'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'main.js', library: { name: 'yourLibrary', type: 'umd', }, globalObject: 'this', }, mode: 'production', module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { presets: ['@babel/preset-env'], }, }, }, ], }, optimization: { minimizer: [new TerserPlugin()], }, plugins: [new CleanWebpackPlugin()], };