Including files in 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