Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 867 Bytes

2017-09-23-npm-publish-include-files.md

File metadata and controls

34 lines (27 loc) · 867 Bytes
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