{"id":20610,"library":"terser-loader","title":"terser-loader","description":"terser-loader is a webpack loader that minifies JavaScript using Terser, a modern ES6+ capable minifier. Version 2.0.3 is the latest stable release, with peer dependency on webpack ^4 || ^5. It offers options like `terserOptions` passed directly to Terser API and `stripTrailingSemicolon`. Unlike the official `terser-webpack-plugin`, this is a loader (not a plugin) integrated in webpack's module rules pipeline, useful for selective minification alongside other loaders. Low release cadence but functional for specific use cases.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/5lava/terser-loader","tags":["javascript","uglify","uglify-js","uglify-es","terser","webpack","webpack-loader","minification","compress"],"install":[{"cmd":"npm install terser-loader","lang":"bash","label":"npm"},{"cmd":"yarn add terser-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add terser-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency – requires webpack 4 or 5 to function","package":"webpack","optional":false}],"imports":[{"note":"ESM default import; CommonJS require works but not recommended for modern webpack configs if using ESM.","wrong":"const TerserLoader = require('terser-loader');","symbol":"terser-loader","correct":"import TerserLoader from 'terser-loader';"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  module: {\n    rules: [\n      {\n        test: /\\.js$/,\n        use: [\n          {\n            loader: 'terser-loader',\n            options: {\n              terserOptions: {\n                compress: {\n                  drop_console: true,\n                },\n              },\n              stripTrailingSemicolon: true,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  mode: 'production',\n};\n","lang":"javascript","description":"Configures terser-loader to minify all .js files, removing console.log and trailing semicolons. Use in production builds."},"warnings":[{"fix":"If you need bundle-level minification, use terser-webpack-plugin instead.","message":"Loader is not a plugin; it runs on each module individually, not on the final bundle. Use terser-webpack-plugin for bundle-level minification.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade webpack to ^4 || ^5, or stick to terser-loader@1 for webpack 3.","message":"Version 2.0.0 dropped support for webpack <4.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use terserOptions.output.semicolon = false instead.","message":"The stripTrailingSemicolon option is non-standard and may be removed in future versions.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install terser as a dev dependency: npm install --save-dev terser","cause":"Missing Terser peer dependency","error":"Module not found: Error: Can't resolve 'terser'"},{"fix":"Check terserOptions for valid Terser options; do not use options like 'output' directly on the loader.","cause":"Options passed are not recognized","error":"ValidationError: Invalid options object. Terser Loader has been initialized using an options object that does not match the API schema."},{"fix":"Upgrade webpack to version 4 or 5, or install terser-loader@1","cause":"Using terser-loader@2 with webpack 3 or lower","error":"Error: webpack <4 is not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}