The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Change working directory of "publish" script
I have a lib written in TypeScript that compile into a “dist” folder. I want to publish the content of that folder and not the content of the root of my project. This is because I want the lib consumers to be able to require the lib components this way:
This last form doesn’t make sense because the dist folder doesn’t serve any kind of semantic in the distributed package - it only exists in the distributed package because I don’t know how to remove it.
I tried to change directory on the prepublish script but it’s not propagated to the publish script.
How can I do that?
You would copy the contents of the
dist folder to the root folder.
I’m already doing this. But this implies adding a lot of things to .gitignore and it’s not super clean. I was hoping for an official and clean way to handle this.
You can use the
.npmignore for that which gives a better separation between what git needs to know and what npm needs to know: https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package