{"id":20184,"library":"last-call-webpack-plugin","title":"Last Call Webpack Plugin","description":"A Webpack plugin that allows transforming/modifying assets just before Webpack emits them. Version 3.0.0 supports Webpack 4+, while v2.1.2 is for Webpack 3 and below. The plugin accepts an array of asset processors, each with a regex to match asset names and a processor function returning a Promise. It provides an assets object for adding, deleting, or retrieving assets during processing. Useful for prefixing comments, running final optimizations (e.g., cssnano), or generating additional assets like source maps. Compared to other asset modification plugins, it offers explicit per-processor phase control and direct asset manipulation.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/NMFR/last-call-webpack-plugin","tags":["javascript","transform","modify","manipulate","optimize","prefix","sufix","webpack","assets"],"install":[{"cmd":"npm install last-call-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add last-call-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add last-call-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package uses CommonJS export; ESM import may fail in Node without a bundler. Use require() in Webpack config.","wrong":"import LastCallWebpackPlugin from 'last-call-webpack-plugin';","symbol":"LastCallWebpackPlugin","correct":"const LastCallWebpackPlugin = require('last-call-webpack-plugin');"},{"note":"If using ESM with bundler (e.g., Webpack itself), default import works. Do not destructure named export.","wrong":"const { LastCallWebpackPlugin } = require('last-call-webpack-plugin');","symbol":"LastCallWebpackPlugin (ESM)","correct":"import LastCallWebpackPlugin from 'last-call-webpack-plugin';"},{"note":"Options must be passed as an object with key 'assetProcessors'; the constructor expects an options object.","wrong":"new LastCallWebpackPlugin(assetProcessors: [...])","symbol":"Constructor options","correct":"new LastCallWebpackPlugin({ assetProcessors: [...], canPrint: true })"}],"quickstart":{"code":"const LastCallWebpackPlugin = require('last-call-webpack-plugin');\nconst cssnano = require('cssnano');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'bundle.js'\n  },\n  plugins: [\n    new LastCallWebpackPlugin({\n      assetProcessors: [\n        {\n          regExp: /\\.js$/,\n          processor: (assetName, asset) => Promise.resolve('// Author: John Doe\\n' + asset.source())\n        },\n        {\n          regExp: /\\.css$/,\n          processor: (assetName, asset, assets) => cssnano.process(asset.source()).then(r => r.css)\n        }\n      ],\n      canPrint: true\n    })\n  ]\n};","lang":"javascript","description":"Shows typical usage with two processors: one to prepend a comment to JS files, another to minify CSS files using cssnano."},"warnings":[{"fix":"Downgrade to last-call-webpack-plugin@2.1.2 if using Webpack < 4.","message":"v3.0.0 requires Webpack 4 or higher; v2.x for Webpack 3 and below.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Consider using 'compilation.optimize-assets' or 'emit' phase instead.","message":"Option phase: 'compilation.optimize-chunk-assets' may be deprecated in Webpack 5.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Ensure processor returns a Promise or use async/await. For synchronous transforms, wrap in Promise.resolve().","message":"processor function must return a Promise or a value (if synchronous). Asynchronous behavior relies on Promise.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use getAsset() to check existence before deleting, or catch errors.","message":"The assets setAsset() method with null deletes the asset; does not provide feedback if asset missing.","severity":"gotcha","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":"Use require('last-call-webpack-plugin') instead of import.","cause":"Using ESM import syntax with CommonJS-only module.","error":"TypeError: LastCallWebpackPlugin is not a constructor"},{"fix":"Match plugin version to Webpack version: v2 for Webpack 3, v3 for Webpack 4+.","cause":"Trying to use v2 with Webpack 4 or v3 with Webpack 3.","error":"Error: webpack v4+ only supports last-call-webpack-plugin@3"},{"fix":"Check if asset.source exists, or use asset.buffer()/asset.content() depending on Webpack version.","cause":"processor receives webpack asset object, which may not have source() in older webpack versions or custom asset types.","error":"TypeError: asset.source is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}