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-reporter-static-files-copy

v1.5.3

Published

ParcelJS v2 plugin to copy static files from static dir to bundle directory.

Downloads

59,294

Readme

parcel-reporter-static-files-copy

ParcelJS v2 plugin to copy static files from some directory to output dir. There is no watcher - files are copied on the build finish.

Install

yarn add parcel-reporter-static-files-copy --dev
npm install -D parcel-reporter-static-files-copy

Usage

  1. Create a static directory in your project root.
  2. Fill it with your static files
  3. Add plugin to .parcelrc:
{
  "extends": ["@parcel/config-default"],
  "reporters":  ["...", "parcel-reporter-static-files-copy"]
}

PLEASE NOTE: "..." is not a placeholder - it is used to extend the default list of plugins (reporters in this case). Please see Parcel's plugins documentation for more information.

  1. Run build - and that's all! Files from the static directory will end up in dist!

Customization

Beyond the default settings, you can:

  1. Name of the directory to be copied.
// package.json
  {
  ...
  "staticFiles": {
    "staticPath": "customStatic"
  }
  1. Specify a directory to copy static files into

If files from staticPath needs to get copied into a subdirectory inside the dist dir - staticOutPath can be used:

// package.json
  {
  ...
  "staticFiles": {
    "staticOutPath": "vendor"
  }
  1. Destination of static files

The destination of static files can be set in plugin configuration. It will override --dist-dir parameter.

// package.json
  {
  ...
  "staticFiles": {
    "distDir": "customDist"
  }
  1. Multiple static folders

staticFiles entry in package.json can be set to the array of configurations instead of a single config. Thanks to that it is possible e.g. to copy files from different directories to the output package.

For example please see the example below with environmental variables.

  1. Different static files/folders based on the environmental variable

Different static files/folders can be copied based on the environmental variables using env map for config. There can be more than one variable to match - in that case, ALL must be the same. If env map is omitted - file(s) will be always copied.

The example below - when NODE_ENV is set to production then production.txt will be copied and if set to development then development.txt:

// package.json
  {
  ...
  "staticFiles": [
    {
      "staticPath": "production.txt",
      "env": {
        "NODE_ENV": "production"
      }
    },
    {
      "staticPath": "development.txt",
      "env": {
        "NODE_ENV": "development"
      }
    }
  ]

Additional example

Check examples directory for additional examples.

Flaws and problems

At this moment this plugin copies all static files from some static dir to the output (dist) directory. There is no watcher on static files - the only trigger is finishing the build (no matter if normal build or serving).

Contribute

You're interested in contributing? Awesome! Fork, make changes, commit and create pull requests. I'll do my best to merge changes!

Thanks and acknowledgement

Special thanks to @gmougeolle.

License

MIT