Registry / devops / webpack-dynamic-public-path

webpack-dynamic-public-path

JSON →
library1.0.8jsnpmunverified

Webpack 4 plugin to replace the static publicPath in generated chunks with a JavaScript expression (e.g., a global variable or a hardcoded string). Version 1.0.8 is the latest stable release; no updates for several years. Unlike webpack 5's built-in __webpack_public_path__ or automatic-publicPath, this plugin works with webpack 4 and allows per-chunk assignment of publicPath. It is intended for legacy projects that cannot upgrade to webpack 5.

npm install webpack-dynamic-public-path
INSTALL
IMPORT
SIG · WEBPACK-DYNAMIC-PU
W
webpack-dynamic-public-path
devopsjavascriptv1.0.8
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.

WebpackDynamicPublicPathPlugin
const WebpackDynamicPublicPathPlugin = require('webpack-dynamic-public-path');
import WebpackDynamicPublicPathPlugin from 'webpack-dynamic-public-path';
Package does not ship ESM; CommonJS require is required. Using import may cause errors in Node.js.

Shows a minimal webpack 4 config using the plugin to replace the static publicPath placeholder with a window variable.

// webpack.config.js const path = require('path'); const WebpackDynamicPublicPathPlugin = require('webpack-dynamic-public-path'); module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), publicPath: 'PUBLIC_PATH_PLACEHOLDER', }, plugins: [ new WebpackDynamicPublicPathPlugin({ externalPublicPath: 'window.myPublicPath', }), ], };
Debug
Known issues
breakingPlugin only works with webpack 4. Using with webpack 5 will cause undefined behavior or compilation errors.
fix
Use webpack 5's built-in __webpack_public_path__ or automatic-publicPath guide (https://webpack.js.org/guides/public-path/#automatic-publicpath).
affects: >=5.0.0 of webpack
deprecatedPackage has not been updated since 2019 and is considered deprecated. No support for future webpack versions.
fix
Migrate to webpack 5+ or consider using runtime publicPath mechanism.
affects: all
gotchaThe externalPublicPath option expects a raw JavaScript expression, not a string literal. For a string constant, wrap in quotes like '"./"' (note single quotes inside double quotes).
fix
Set externalPublicPath to '"./"' (including single quotes) for a static string, or to a variable reference without quotes.
affects: all
gotchaIf not using chunkNames, publicPath is replaced in ALL chunks. This can break vendor bundles or async chunks if they need a different publicPath.
fix
Always specify chunkNames when multiple entries or code splitting is used to avoid unintended replacements.
affects: all
Errors
Common errors & fixes
TypeError: Cannot read property 'tapAsync' of undefined
Using the plugin with webpack 5 (or incompatible version) where the hooks API changed.
fix
Downgrade to webpack 4 or switch to webpack 5 native publicPath handling.
Module not found: Error: Can't resolve 'webpack-dynamic-public-path'
Package not installed or import path incorrect (e.g., using ESM import).
fix
Install with 'npm install webpack-dynamic-public-path' and use require('webpack-dynamic-public-path').
Upgrade
Version history
1.0.8latest on npm
Audit
Dependencies
webpackrequiredpeer dependency – plugin is designed for webpack 4 only
Agent activity
9 hits · last 30 days
node
8
Resources
webpack-dynamic-public-path — npm install webpack-dynamic-public-path · libregistry