Parcel plugin that allows you to ignore assets/import syntax from bundling.
npm install parcel-resolver-ignore!Version



> đ Parcel plugin that allows you to ignore assets/import syntax from bundling.
``sh`Installs the plugin and saves it as a development dependency
npm i parcel-resolver-ignore -D
We need to create .parcelrc configuration file and add the plugin to resolvers like this:
> Syntax "..." instructs Parcel to apply the plugin on top of existing resolvers
`js`
{
"extends": "@parcel/config-default",
"resolvers": ["parcel-resolver-ignore", "..."]
}
Sometimes, some of our files are not available at build time or we simply don't
want Parcel to process them. Or maybe we use special templating syntax for
importing files that Parcel doesn't recognize and throws an error.
This is where parcel-resolver-ignore comes into play.
You can find example use-cases below.
> âšī¸ NOTE: Examples below are HTML files, but the plugin works with EVERY file (i.e. CSS).
1. Excluding files from processing
package.json
`jsonc`
{
// An array of Regex patterns
"parcelIgnore": [
"jquery.min.js",
"privacy-policy.html",
"images/.+"
]
}
index.html
`html


`
2. Ignoring special syntax (i.e. from templating engines)
package.json
`jsonc`
{
// An array of Regex patterns
"parcelIgnore": [
"{{.*}}"
]
}
index.html
`html
3. Ignoring files based on NODE_ENV value : "development" (
parcel serve) or "production" (parcel build) or custom.package.json
`jsonc
{
// An object containing dev and/or prod files to ignore
"parcelIgnore": {
"development": [
"privacy-policy.html",
"images/.+"
],
"production": [
"jquery.min.js",
"images/.+"
],
"test": [
"jquery.min.js"
]
}
}`index.html
`html
Document
My Title
File not available at build time.


`$3
`sh
parcel build src/index.html # Success!
`:wrench: Troubleshooting
If you ran Parcel just before adding this plugin, it's possible that stale Parcel caches are causing build failures. First, try to delete the caches folder
.parcel-cache` in your project's root directory.Vladimir Mikulic
- Twitter: @VladoDev
- Github: @VladimirMikulic
- LinkedIn: @vladimirmikulic
Contributions, issues and feature requests are welcome!
This project is licensed under MIT license.
Give a âī¸ if this project helped you!