{"id":20635,"library":"uglify-loader","title":"uglify-loader","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/bestander/uglify-loader","tags":["javascript","webpack","loader"],"install":[{"cmd":"npm install uglify-loader","lang":"bash","label":"npm"},{"cmd":"yarn add uglify-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add uglify-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core minification library","package":"uglify-js","optional":false},{"reason":"Loader runs within webpack build pipeline","package":"webpack","optional":false}],"imports":[{"note":"Loader is referenced by name in webpack config, not imported directly.","wrong":"const uglifyLoader = require('uglify-loader'); // Not used directly; use string reference","symbol":"default","correct":"import uglifyLoader from 'uglify-loader'; // in webpack config as string 'uglify-loader'"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        exclude: /node_modules/,\n        use: {\n          loader: 'uglify-loader',\n          options: {\n            mangle: true,\n            compress: { sequences: true, dead_code: true, conditionals: true }\n          }\n        }\n      }\n    ]\n  }\n};","lang":"javascript","description":"Webpack configuration using uglify-loader on .js files excluding node_modules, with custom UglifyJS options."},"warnings":[{"fix":"Use terser-webpack-plugin for webpack 4+ or upgrade to webpack 5 compatible minifier.","message":"uglify-loader 3.x only supports webpack 4+. Using with webpack 5 may cause issues; consider terser-webpack-plugin instead.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Move UglifyJS options into the loader's options object in webpack config.","message":"Loader options via webpack config property 'uglify-loader' is deprecated in webpack 2+. Use loader options instead.","severity":"deprecated","affected_versions":"<3.0.0"},{"fix":"Ensure UglifyJS options handle global definitions properly or use a bundle-level minifier.","message":"The loader minifies each module individually, which may break global variable references if not careful.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure the test pattern only matches .js files and exclude other file types.","cause":"uglify-loader expects valid JavaScript input; it cannot handle non-JS files like CSS or TypeScript.","error":"Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type."},{"fix":"Use the string 'uglify-loader' in the rules configuration, not the plugin.","cause":"Confusing uglify-loader with webpack's built-in UglifyJsPlugin.","error":"Configuration file had an error: Error: webpack.optimize.UglifyJsPlugin is not a plugin"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}