I am looking for a good way to ignore all .ts files in a project when I publish to NPM, I can do that by adding the following to my .npmignore
file:
*.ts
but wait..actually I want to keep all the .d.ts
files in my project, when I publish...
What can I add to my .npmignore file that will keep all .d.ts
files but ignore all .ts
files?
I assumed I have to use some form of regex to ignore all files that end with .ts that do not end with .d.ts
so the JS regex for this might look like:
*.\.[^d]\.ts
what the above regex should mean is match anything that ends with .ts that does not end with .d.ts
but of course we are stuck with what I believe to be less powerful regexes used by the OS etc.
In the docs for .npmignore it states:
.npmignore
files follow the same pattern rules as.gitignore
files:
In which case you can negate the .d.ts
files in .npmignore
by using !
. For example in your .npmignore
you simply:
# ignore the .ts files
*.ts
# include the .d.ts files
!*.d.ts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With