layout | title | date | excerpt | categories |
---|---|---|---|---|
post |
Including files in npm publish |
2017-09-23 20:36:38 -4000 |
How to include and exclude files during npm publish. |
npm publish |
npm looks at .gitignore
to figure out what files/directories to blacklist when a package is being published to the registry.
But what if there are files/directories specified in .gitignore
that you want to include in the publish?
# .gitignore
dist/
build/
You can whitelist the directories (as well as any other files) in package.json
:
{
"files": [
"dist/",
"build/"
]
}
Alternatively, you can create an empty .npmignore
because it takes precedence over .gitignore
:
$ touch .npmignore