{"id":13657794,"url":"https://github.com/kuldeepkeshwar/dynamic-public-path","last_synced_at":"2025-10-12T16:25:04.906Z","repository":{"id":57217706,"uuid":"98848655","full_name":"kuldeepkeshwar/dynamic-public-path","owner":"kuldeepkeshwar","description":"Webpack Plugin for dynamic public path ","archived":false,"fork":false,"pushed_at":"2019-11-08T12:44:49.000Z","size":27,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-02T12:42:00.246Z","etag":null,"topics":["dynamic-public-path","webpack","webpack-public-path"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuldeepkeshwar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-31T04:40:05.000Z","updated_at":"2022-09-27T15:55:35.000Z","dependencies_parsed_at":"2022-08-28T21:40:33.591Z","dependency_job_id":null,"html_url":"https://github.com/kuldeepkeshwar/dynamic-public-path","commit_stats":null,"previous_names":["kuldeepkeshwar/dynamic-webpack-plugin"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepkeshwar%2Fdynamic-public-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepkeshwar%2Fdynamic-public-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepkeshwar%2Fdynamic-public-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepkeshwar%2Fdynamic-public-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuldeepkeshwar","download_url":"https://codeload.github.com/kuldeepkeshwar/dynamic-public-path/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233757928,"owners_count":18725643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-public-path","webpack","webpack-public-path"],"created_at":"2024-08-02T05:00:51.075Z","updated_at":"2025-09-21T13:32:57.040Z","avatar_url":"https://github.com/kuldeepkeshwar.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# dynamic-public-path [![Build Status](https://travis-ci.org/kuldeepkeshwar/dynamic-public-path.svg?branch=master)](https://travis-ci.org/kuldeepkeshwar/dynamic-public-path)\nthis plugin is to allow webpack to use publicPath value that isn't known at build time.\n\nThis generate a boot file which allows you to load bundles from other projects built with webpack at runtime. \n\nIt is extremely helpful when you prepare a build for library with multiple entry points allowing you to load library chunks on demand.\n\nor if you are trying to show views from multiple apps into a single app.\n(instead of exposing child app as npm module \u0026 adding to your app at build time, you can use them directly at runtime) \n\n For now it works with options `library` \u0026 `libraryTarget` as 'umd'\n## install\n```\nnpm install dynamic-public-path\n```\n\n## example\nlet say we want to publish `MyLibrary` which expose 2 bundles  `a.js` \u0026 `b.js`\n#### a.js\n```\nexport default {value:10}\n```\n#### b.js\n```\nexport default {value:20}\n```\n#### library.webpack.config.js\n```\n const DynamicPublicPathPlugin = require('dynamic-public-path');\n const config = {\n  entry: {\n    a: ['a.js'],\n    b: ['b.js']\n  },\n  output: {\n    path: __dirname + '/lib',\n    filename: '[name].js',\n    chunkFilename: '[id].[chunkhash].js',\n    library: ['ab', '[name]'],\n    libraryTarget: 'umd'\n  },\n  plugins:[\n    new DynamicPublicPathPlugin({\n        outputPath: './lib',\n        bootfilename:'my-library.js'\n        global: 'MyLibrary', // gobal variable to access library\n        publicPath: 'window.publicPath'\n    })\n  ]\n }\n```\nabove build will create `my-library.js` under the `lib` folder\n\nAdd `my-library.js` into other project via script tag\n#### index.html \n```\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n  \u003ctitle\u003eReact App\u003c/title\u003e\n\t\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\n\t\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.js\"\u003e\u003c/script\u003e\n\t\u003cscript src=\"https://test-app/static/my-library.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cdiv class=\"container\"\u003e\n    \u003cdiv id=\"app\"\u003eLoading...\u003c/div\u003e\n\t\u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n```\n#### app.js \n```\nimport MyLibrary from 'MyLibrary'\n\n// set public path \nwindow.publicPath= 'https://test-app/static/';\n\n//or use configure function\n/*\n* MyLibrary.configure({publicPath:'https://test-app/static/'})\n*/\n\nMyLibrary.import('a').then((module)=\u003e{\nconsole.log(module) // {value :10}\n})\nMyLibrary.import('b').then((module)=\u003e{\nconsole.log(module) // {value :20}\n})\n```\n\n # License \n [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuldeepkeshwar%2Fdynamic-public-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuldeepkeshwar%2Fdynamic-public-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuldeepkeshwar%2Fdynamic-public-path/lists"}