Change working directory of "publish" script

(Eric Morand) #1

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:


instead of:


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?

(Markus Tacker) #2

You would copy the contents of the dist folder to the root folder.

(Eric Morand) #3

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.

(Markus Tacker) #4

You can use the .npmignore for that which gives a better separation between what git needs to know and what npm needs to know:

(system) #5

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.