{"id":20751,"library":"webpack-dynamic-public-path","title":"webpack-dynamic-public-path","description":"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.","status":"deprecated","version":"1.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/zahorovskyi/webpack-dynamic-public-path","tags":["javascript","webpack","publicPath","dynamic publicPath"],"install":[{"cmd":"npm install webpack-dynamic-public-path","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-dynamic-public-path","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-dynamic-public-path","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency – plugin is designed for webpack 4 only","package":"webpack","optional":false}],"imports":[{"note":"Package does not ship ESM; CommonJS require is required. Using import may cause errors in Node.js.","wrong":"import WebpackDynamicPublicPathPlugin from 'webpack-dynamic-public-path';","symbol":"WebpackDynamicPublicPathPlugin","correct":"const WebpackDynamicPublicPathPlugin = require('webpack-dynamic-public-path');"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\nconst WebpackDynamicPublicPathPlugin = require('webpack-dynamic-public-path');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    filename: 'bundle.js',\n    path: path.resolve(__dirname, 'dist'),\n    publicPath: 'PUBLIC_PATH_PLACEHOLDER',\n  },\n  plugins: [\n    new WebpackDynamicPublicPathPlugin({\n      externalPublicPath: 'window.myPublicPath',\n    }),\n  ],\n};","lang":"javascript","description":"Shows a minimal webpack 4 config using the plugin to replace the static publicPath placeholder with a window variable."},"warnings":[{"fix":"Use webpack 5's built-in __webpack_public_path__ or automatic-publicPath guide (https://webpack.js.org/guides/public-path/#automatic-publicpath).","message":"Plugin only works with webpack 4. Using with webpack 5 will cause undefined behavior or compilation errors.","severity":"breaking","affected_versions":">=5.0.0 of webpack"},{"fix":"Migrate to webpack 5+ or consider using runtime publicPath mechanism.","message":"Package has not been updated since 2019 and is considered deprecated. No support for future webpack versions.","severity":"deprecated","affected_versions":"all"},{"fix":"Set externalPublicPath to '\"./\"' (including single quotes) for a static string, or to a variable reference without quotes.","message":"The 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).","severity":"gotcha","affected_versions":"all"},{"fix":"Always specify chunkNames when multiple entries or code splitting is used to avoid unintended replacements.","message":"If not using chunkNames, publicPath is replaced in ALL chunks. This can break vendor bundles or async chunks if they need a different publicPath.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Downgrade to webpack 4 or switch to webpack 5 native publicPath handling.","cause":"Using the plugin with webpack 5 (or incompatible version) where the hooks API changed.","error":"TypeError: Cannot read property 'tapAsync' of undefined"},{"fix":"Install with 'npm install webpack-dynamic-public-path' and use require('webpack-dynamic-public-path').","cause":"Package not installed or import path incorrect (e.g., using ESM import).","error":"Module not found: Error: Can't resolve 'webpack-dynamic-public-path'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}