{"id":28459,"library":"webpack-upload-plugin","title":"webpack-upload-plugin","description":"A webpack plugin that uploads JS/CSS/image/font assets to a CDN and replaces local references with CDN URLs. Version 0.25.0 is the latest, works with webpack 3+, but requires explicit configuration for webpack 4 (minimization must be disabled). It does not include its own CDN upload service; users must provide a `cdn` object with an `upload` method. Alternative to other CDN upload plugins, but has known compatibility issues with UglifyJs and requires careful handling of publicPath. Only the plugin owner maintains it; release cadence is sporadic.","status":"maintenance","version":"0.25.0","language":"javascript","source_language":"en","source_url":"https://github.com/liuyuchenzh/webpack-upload-plugin","tags":["javascript","webpack-upload-plugin"],"install":[{"cmd":"npm install webpack-upload-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-upload-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-upload-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency; plugin works with webpack 3+","package":"webpack","optional":false}],"imports":[{"note":"Package does not ship ESM; only CommonJS require is supported. No default import available.","wrong":"import UploadPlugin from 'webpack-upload-plugin'","symbol":"UploadPlugin","correct":"const UploadPlugin = require('webpack-upload-plugin')"},{"note":"The export is a single constructor function, not a named export. Destructuring will yield undefined.","wrong":"const { UploadPlugin } = require('webpack-upload-plugin')","symbol":"UploadPlugin","correct":"const UploadPlugin = require('webpack-upload-plugin')"},{"note":"The second argument (options) is optional. If not provided, defaults are used.","wrong":"new UploadPlugin(cdn, {})","symbol":"UploadPlugin","correct":"new UploadPlugin(cdn)"}],"quickstart":{"code":"const path = require('path');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst MiniCssExtractPlugin = require('mini-css-extract-plugin');\nconst UploadPlugin = require('webpack-upload-plugin');\n\n// You must provide your own CDN upload function\nconst cdn = {\n  upload: (localPaths) => {\n    // Simulated upload: map local paths to CDN URLs\n    return Promise.all(localPaths.map((localPath) => {\n      const cdnUrl = 'https://cdn.example.com/' + path.basename(localPath);\n      return { [localPath]: cdnUrl };\n    })).then((pairs) => pairs.reduce((acc, pair) => Object.assign(acc, pair), {}));\n  }\n};\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n    publicPath: ''\n  },\n  module: {\n    rules: [\n      { test: /\\.js$/, loader: 'babel-loader' },\n      { test: /\\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'] },\n      { test: /\\.(png|jpe?g|gif|svg)(\\?.*)?$/, loader: 'url-loader', options: { limit: 10000 } }\n    ]\n  },\n  optimization: { minimize: false },\n  plugins: [\n    new MiniCssExtractPlugin({ filename: '[name].css' }),\n    new HtmlWebpackPlugin({ template: 'index.html', inject: true }),\n    new UploadPlugin(cdn)\n  ]\n};","lang":"javascript","description":"Shows a minimal webpack config using the plugin with a simulated CDN uploader."},"warnings":[{"fix":"Set `optimization.minimize: false` in webpack config, or use `beforeUpload` callback to compress files before upload.","message":"For webpack@4, set optimization.minimize to false! This plugin does not work with UglifyJs plugin.","severity":"breaking","affected_versions":">=0.25.0"},{"fix":"Downgrade to version 0.20.0 or upgrade webpack to 3+.","message":"For webpack@2, use webpack-upload-plugin <= 0.20.0. This version is incompatible.","severity":"deprecated","affected_versions":">=0.21.0"},{"fix":"Set `output.publicPath` to empty string in webpack config.","message":"publicPath should be set to '' (empty string) for correct CDN URL replacement. Other values may cause broken paths.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure UploadPlugin is the last plugin in the plugins list.","message":"Plugin must be placed after any copy-related plugins (e.g., CopyWebpackPlugin) in the plugins array.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Disable UglifyJs plugin or set optimization.minimize to false.","cause":"Using UglifyJs plugin with webpack 4 and this plugin, which requires minimize: false","error":"TypeError: UglifyJsPlugin is not a function"},{"fix":"Run npm i -D webpack-upload-plugin and ensure require path is correct.","cause":"Missing npm installation or incorrect import path","error":"Cannot find module 'webpack-upload-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}