Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Scripts to streamline/enforce the copy and publish subdir method ( idk if copying package.json is necessary
"prepublishOnly": "if [[ ! $PWD =~ dist$ ]]; then npm run _dist:nopublish; fi",
"_dist:nopublish": "echo 'Use `npm run dist` instead of `npm publish`!' && exit 1",
"_dist:prep": "yarn build && cp package.json dist && cp dist",
"_dist:post": "rm -f dist/package.json && rm -f dist/",
"dist": "npm run _dist:prep && npm publish dist && npm run _dist:post"

This comment has been minimized.

Copy link

@sandrina-p sandrina-p commented Oct 15, 2020

Thanks for sharing!

It almost worked in my case, the only change I add to make was the dist path:

-       "dist": "npm run _dist:prep && npm publish dist && npm run _dist:post"
+       "dist": "npm run _dist:prep && npm pack ./dist && npm run _dist:post"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.