Registry / devops / uglify-loader

uglify-loader

JSON →
library3.0.0jsnpmunverified

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-loader
INSTALL
IMPORT
SIG · UGLIFY-LOADER
U
uglify-loader
devopsjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import uglifyLoader from 'uglify-loader'; // in webpack config as string 'uglify-loader'
const uglifyLoader = require('uglify-loader'); // Not used directly; use string reference
Loader is referenced by name in webpack config, not imported directly.

Webpack configuration using uglify-loader on .js files excluding node_modules, with custom UglifyJS options.

// webpack.config.js module.exports = { module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: 'uglify-loader', options: { mangle: true, compress: { sequences: true, dead_code: true, conditionals: true } } } } ] } };
Debug
Known issues
breakinguglify-loader 3.x only supports webpack 4+. Using with webpack 5 may cause issues; consider terser-webpack-plugin instead.
fix
Use terser-webpack-plugin for webpack 4+ or upgrade to webpack 5 compatible minifier.
affects: >=3.0.0
deprecatedLoader options via webpack config property 'uglify-loader' is deprecated in webpack 2+. Use loader options instead.
fix
Move UglifyJS options into the loader's options object in webpack config.
affects: <3.0.0
gotchaThe loader minifies each module individually, which may break global variable references if not careful.
fix
Ensure UglifyJS options handle global definitions properly or use a bundle-level minifier.
affects: *
Errors
Common errors & fixes
Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type.
uglify-loader expects valid JavaScript input; it cannot handle non-JS files like CSS or TypeScript.
fix
Ensure the test pattern only matches .js files and exclude other file types.
Configuration file had an error: Error: webpack.optimize.UglifyJsPlugin is not a plugin
Confusing uglify-loader with webpack's built-in UglifyJsPlugin.
fix
Use the string 'uglify-loader' in the rules configuration, not the plugin.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
uglify-jsrequiredCore minification library
webpackrequiredLoader runs within webpack build pipeline
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
uglify-loader — npm install uglify-loader · libregistry