A webpack loader that applies UglifyJS minification (with mangling) to individual modules during bundling, as opposed to the webpack UglifyJSPlugin which minifies the entire output after bundling. Version 3.0.0 is the latest stable release, targeting webpack 4+. The loader allows selective minification of application code while preserving third-party libraries, and supports custom UglifyJS options via loader options. It is maintained by the community and sees infrequent updates.
npm install uglify-loaderVerified import paths — ran on the pinned version, not inferred.
Webpack configuration using uglify-loader on .js files excluding node_modules, with custom UglifyJS options.
Use terser-webpack-plugin for webpack 4+ or upgrade to webpack 5 compatible minifier.
Move UglifyJS options into the loader's options object in webpack config.
Ensure UglifyJS options handle global definitions properly or use a bundle-level minifier.
Ensure the test pattern only matches .js files and exclude other file types.
Use the string 'uglify-loader' in the rules configuration, not the plugin.