Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
UploadPlugin
✓ const UploadPlugin = require('webpack-upload-plugin')
✗ import UploadPlugin from 'webpack-upload-plugin'
Package does not ship ESM; only CommonJS require is supported. No default import available.
UploadPlugin
✓ const UploadPlugin = require('webpack-upload-plugin')
✗ const { UploadPlugin } = require('webpack-upload-plugin')
The export is a single constructor function, not a named export. Destructuring will yield undefined.
UploadPlugin
✓ new UploadPlugin(cdn)
✗ new UploadPlugin(cdn, {})
The second argument (options) is optional. If not provided, defaults are used.
Shows a minimal webpack config using the plugin with a simulated CDN uploader.
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UploadPlugin = require('webpack-upload-plugin');
// You must provide your own CDN upload function
const cdn = {
upload: (localPaths) => {
// Simulated upload: map local paths to CDN URLs
return Promise.all(localPaths.map((localPath) => {
const cdnUrl = 'https://cdn.example.com/' + path.basename(localPath);
return { [localPath]: cdnUrl };
})).then((pairs) => pairs.reduce((acc, pair) => Object.assign(acc, pair), {}));
}
};
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: ''
},
module: {
rules: [
{ test: /\.js$/, loader: 'babel-loader' },
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'] },
{ test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url-loader', options: { limit: 10000 } }
]
},
optimization: { minimize: false },
plugins: [
new MiniCssExtractPlugin({ filename: '[name].css' }),
new HtmlWebpackPlugin({ template: 'index.html', inject: true }),
new UploadPlugin(cdn)
]
};
Errors
Common errors & fixes
TypeError: UglifyJsPlugin is not a function
Using UglifyJs plugin with webpack 4 and this plugin, which requires minimize: false
fixDisable UglifyJs plugin or set optimization.minimize to false.
Cannot find module 'webpack-upload-plugin'
Missing npm installation or incorrect import path
fixRun npm i -D webpack-upload-plugin and ensure require path is correct.
Audit
Dependencies
webpackrequiredRequired peer dependency; plugin works with webpack 3+