Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish contents only of a specific folder?

Tags:

npm

How to streamline npm release when I want to include only specific path(s)?

I have ./src and ./dist files in my repository. I want to effectively publish only the contents of ./dist + ./package.json.

Using .npmignore to ignore ./src will simply ignore the ./src folder. I want to include only the contents of ./dist, i.e. now user would need to do require('my-package/dist/something'). I want to make it require('my-package/something'). ./something is contained in ./dist.

like image 920
Gajus Avatar asked Jun 16 '16 14:06

Gajus


1 Answers

The way I have done it at the moment is, I have created a bash script:

npm run build
cp package.json ./dist
# or, if you need to have package.json "main" entry different,
# e.g. for being able to use `npm link`, you need to replace "main" value:
# sed 's#"main": "./dist/index.js"#"main": "./index.js"#' package.json > ./dist/package.json
cd ./dist
npm publish
like image 198
Gajus Avatar answered Sep 28 '22 08:09

Gajus