Thomas W
Thomas W

Reputation: 15371

Include .gitignored files compiled from typescript in `npm install -g`

I'd like to ignore the JavaScript files compiled from TypeScript in my git repo. (That greatly simplifies merging, rebasing, partial commits etc.) The relevant parts of my setup look like this:

tsconfig.json

{
    "compilerOptions": {
      "outDir": "./dist"
    }
}

.gitignore

dist

When installing globally like this:

rm -rf dist
node_modules/.bin/tsc
sudo npm install -g

the gitignored dist folder is not installed. Is there any proper solution to this? The following ones aren't really satisfactory:

Upvotes: 1

Views: 2030

Answers (1)

Thomas W
Thomas W

Reputation: 15371

I solved the problem by putting the following into my package.json:

"files": [
  "/dist"
],

Now, only the dist folder and README.md are packaged/installed. Found out about this possibility from a post by Jeff Dickey.

Upvotes: 3

Related Questions