I know I can't use them both at once, but is there a way to make .npmignore
file extending .gitignore
? I have dozens of rules in .gitignore
and I want to use them all + one additional for npm package. How can I do it without duplicating all the rules?
I don't believe there's any mechanism to do this, but it should be pretty simple to script! Here's how I would tackle this:
Set up a prepack
npm script in your package.json
that:
.gitignore
file to a .npmignore
.npmignore
file after the copy finishes. I would suggest defining these extra rules in a file somewhere, we'll call it extra_rules_file
for clarity in the below example.Then, optionally a postpack
script that deletes your .npmignore
now that you don't need it (and maybe don't want to commit it, since it's a generated file)
For example:
{
"scripts": {
"prepack": "cp .gitignore .npmignore && cat extra_rules_file >> .npmignore",
"postpack": "rm .npmignore"
}
}
whatever/rules/you/want/**/*
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