{"id":21855256,"url":"https://github.com/wix-incubator/resolve-unpkg","last_synced_at":"2025-04-14T18:09:16.461Z","repository":{"id":43687999,"uuid":"122518974","full_name":"wix-incubator/resolve-unpkg","owner":"wix-incubator","description":"Keep your UNPKG links up to date!","archived":false,"fork":false,"pushed_at":"2023-03-20T06:46:59.000Z","size":31,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":160,"default_branch":"master","last_synced_at":"2025-04-14T18:09:11.287Z","etag":null,"topics":["cli","unpkg","unpkg-links"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/wix-incubator.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":"2018-02-22T18:34:58.000Z","updated_at":"2020-07-20T16:34:18.000Z","dependencies_parsed_at":"2022-09-02T08:31:15.536Z","dependency_job_id":null,"html_url":"https://github.com/wix-incubator/resolve-unpkg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fresolve-unpkg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fresolve-unpkg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fresolve-unpkg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wix-incubator%2Fresolve-unpkg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wix-incubator","download_url":"https://codeload.github.com/wix-incubator/resolve-unpkg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933340,"owners_count":21185460,"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":["cli","unpkg","unpkg-links"],"created_at":"2024-11-28T02:14:25.159Z","updated_at":"2025-04-14T18:09:16.430Z","avatar_url":"https://github.com/wix-incubator.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://image.ibb.co/nR99Wy/svg_resolveunpkg_github.png\"/\u003e\n\u003c/p\u003e\n\n[![Build Status](https://travis-ci.org/wix-incubator/resolve-unpkg.svg)](https://travis-ci.org/wix-incubator/resolve-unpkg) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\nThe **Resolve-Unpkg** library helps you to keep your unpkg links up to date by patching the unpkg URLs with the package version installed in your environment. The **Resolve-Unpkg** may be used in command line and as a webloader.\n\n**TL;DR;**\n\n\u003e In CLI:\n\u003e ```bash\n\u003e    npm i --save-dev resolve-unpkg\n\u003e    resolve-unpkg path-to-optional-config.json\n\u003e ```\n\u003e\n\u003e Webloader:\n\u003e ```javascript\n\u003e    import scripts from '!resolve-unpkg?unpkgPrefix=unpkg.com\u0026versionPlaceholder=a.b.c\u0026onlyByVersionPlaceholder=true!scripts.json';\n\u003e ```\n\n\u003c!-- TOC --\u003e\n\n- [Import](#import)\n- [Configuration](#configuration)\n- [Usage in CLI](#usage-in-cli)\n- [Usage in JS](#usage-in-js)\n\n\u003c!-- /TOC --\u003e\n\n# Import\n\nTo add **Resolve-Unpkg** to the project, `cd` to the project root folder and run:\n\n`npm i --save-dev resolve-unpkg`\n\nThis will add **Resolve-Unpkg** as a dependency to *package.json* enabling you to run the `resolve-unpkg` command manually and use resolve-unpkg as a webpack loader to resolve versions in unpkg URLs when they are imported from the JSON file.\n\n# Configuration\n\nBy default, **Resolve-Unpkg** processes URLs with `unpkg.com` prefix in the *index.html* file and replaces the *x.x.x* version placeholders with the actual version of the packages that are installed in your local environment.\n\nTo customize the default configuration, use the following options:\n\n| Property         | Type       | Required | Description                              | CLI | Loader |\n| ---------------- | ---------- | :------: | ---------------------------------------- | :-: | :----: |\n| `unpkgPrefix`    | `string`   |   No     | The prefix of the unpkg URLs. Default: `'unpkg.com'` | Yes | Yes |\n| `versionPlaceholder`| `string`   |   No     | A version number placeholder to be replaced when occurs in the position of package version. Default: `'x.x.x'`  | Yes | Yes |\n| `onlyByVersionPlaceholder`  | `boolean`   |   No     |  A flag that may limit the update to those URLs that contain the versionPlaceholder (e.g. x.x.x); when set to `true`, the exact package version numbers, like 1.9.1, are ignored. Default: `true`     | Yes | Yes |\n| `files`    | `string[]`   |   No     | Path to file(s) to update/resolve URLs in. Default: `['index.html']` | Yes | No |\n| `dist`    | `string`   |   No     | Folder where the updated file(s) should be saved. Default: overwrite original | Yes | No |\n\n# Usage in CLI\n\nWith **Resolve-Unpkg**, you can automatically update the package versions that are mentioned in the unpkg URLs in some of your project files.\n\n\u003e The package versions used are those installed in your local environment.\n\nBefore you begin, prepare the resolve-unpkg configuration file to override the default options if necessary. For example:\n\n**Sample Resolve-Unpkg configuration file**\n\n```\n{\n  \"unpkgPrefix\": \"unpkg\",\n  \"files\": [\"index.vm, index.ejs\"],\n  \"dist\": \"dist/\"\n}\n```\n\nTo update the unpkg links, run:\n\n`resolve-unpkg [optional-config.json]`\n\nAs a result, the unpkg URLs in the provided files will be updated.\n\nAs an illustration to this process, let's consider the following file (`index.html`) :\n\n```html\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003clink rel=\"stylesheet\" href=\"https://unpkg.com/spectrum-colorpicker@1.6.0/spectrum.css\"\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cscript src=\"https://unpkg.com/jquery@x.x.x/dist/jquery.min.js\"\u003e\u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n``` \n\nIf the version of the `jquery` installed in the local environment is `'2.21'`, and `spectrum-colorpicker` is `'1.6.1'`, and we run the `resolve-unpkg` with default configuration parameters, the original `index.html` file will be overwritten with this one:\n\n```html\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003clink rel=\"stylesheet\" href=\"https://unpkg.com/spectrum-colorpicker@1.6.0/spectrum.css\"\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cscript src=\"https://unpkg.com/jquery@2.2.1/dist/jquery.min.js\"\u003e\u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nNote that as the `onlyByVersionPlaceholder` is `true` by default, the older version for *spectrum-colorpicker* was not modified. \n\n# Usage in JS\n\nFor the unpkg links that are imported into your JS code from the JSON file, use **resolve-unpkg** loader to inject the updated versions into the URLs. To do so, update the import and provide the necessary values as parameters:\n\n```javscript\n...\nimport scripts from '!resolve-unpkg?unpkgPrefix=unpkg.com\u0026versionPlaceholder=a.b.c\u0026onlyByVersionPlaceholder=true!scripts.json';\n...\n``` \n\n# Testing\n\nMake sure to test the new version since every time your links are updated you are getting code that has not yet run through your tests. So if for example you use `resolve-unpkg` in your build phase, you should have your code tested afterwards (e.g. in E2E tests).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwix-incubator%2Fresolve-unpkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwix-incubator%2Fresolve-unpkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwix-incubator%2Fresolve-unpkg/lists"}