npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

parcel-resolver-ignore

v2.2.0

Published

Parcel plugin that allows you to ignore assets/import syntax from bundling.

Downloads

36,190

Readme

parcel-resolver-ignore

Version License: MIT CI Twitter: VladoDev

🌀 Parcel plugin that allows you to ignore assets/import syntax from bundling.

:package: Installation

# Installs the plugin and saves it as a development dependency
npm i parcel-resolver-ignore -D

🔌 Configuration

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

{
  "extends": "@parcel/config-default",
  "resolvers": ["parcel-resolver-ignore", "..."]
}

:cloud: Usage

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

{
  // An array of Regex patterns
  "parcelIgnore": [
    "jquery.min.js",
    "privacy-policy.html",
    "images/.+"
  ]
}

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <h1>My Title</h1>
    <!-- This won't throw build error -->
    <a href="./privacy-policy.html">File not available at build time.</a>

    <!-- These won't be processed by Parcel -->
    <img src="./images/my-image.png" alt="my PNG image" />
    <img src="./images/my-image.jpg" alt="my JPG image" />
    <script src="jquery.min.js"></script>
  </body>
</html>
  1. Ignoring special syntax (i.e. from templating engines)

package.json

{
  // An array of Regex patterns
  "parcelIgnore": [
    "{{.*}}"
  ]
}

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <h1>My Title</h1>
    <!-- This won't throw build error -->
    <script src="{{scriptSrc}}"></script>
  </body>
</html>
  1. Ignoring files based on NODE_ENV value : "development" (parcel serve) or "production" (parcel build) or custom.

package.json

{
  // 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

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <h1>My Title</h1>
    <!-- This won't throw build error -->
    <a href="./privacy-policy.html">File not available at build time.</a>

    <!-- These won't be processed by Parcel -->
    <img src="./images/my-image.png" alt="my PNG image" />
    <img src="./images/my-image.jpg" alt="my JPG image" />
    <script src="jquery.min.js"></script>
  </body>
</html>

🚀 Build

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.

:man: Author

Vladimir Mikulic

:handshake: Contributing

Contributions, issues and feature requests are welcome!

:pencil: License

This project is licensed under MIT license.

:man_astronaut: Show your support

Give a ⭐️ if this project helped you!