A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time.
npm i -D sourcemap-publishernpx sourcemap-publisher --provenanceThis will do the following:
- Load the files in your
filesarray inpackage.json - Find the sourcemaps any of these files reference
- Package up these sourcemaps under
{packageName}@{version}-sourcemaps - Rewrite the sourcemap URLs in the original sources to point at a CDN for this sourcemap package
You should run this command after your build, but before you publish.
It is important to get the ordering right so you do not overwrite the rewritten sourcemap URLs.
Generally, the order should be as follows:
- Build your package
- Run
sourcemap-publisherto publish the sourcemaps and rewrite the URLs - Run
npm publishto publish the rewritten sources
You can achieve this through a prepublishOnly script in your package.json:
{
"scripts": {
"prepublishOnly": "npm run build && sourcemap-publisher --provenance"
}
}| Option | Description |
|---|---|
--provenance |
Publish to npm with --provenance enabled |
--dry-run |
Do not publish, run npm publish --dry-run |
MIT