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

esbuild-plugin-php-manifest

v1.0.0

Published

Plugin for esbuild that'll generate a php manifest which contains an key value array with the input and outputs

Downloads

3

Readme

esbuild-plugin-php-manifest

This Plugin will generate a PHP File that contains a Class with a static Associative Array with the key being the Input File and the value being the Output.

This Plugin was inspired by webpack-php-manifest

Example Output

// generated PHP Manifest
<?php
  class EsbuildPluginPhpManifest {
    static $files = [
        "test.js" => "out/test-2XYBNIBO.js"
      ];
  };

That File can then be used to include the generated assets. I'd advise to use a hash for cache busting purposes.

Sample Usage inside a PHP File

<?php require_once __DIR__ . "/manifest.php"; ?>
<script src="<?= EsbuildPluginPhpManifest::$files["test.js"] ?>"></script>

Install

npm install -D esbuild esbuild-plugin-php-manifest

Usage

const esbuild = require('esbuild');
const phpManifestPlugin = require('esbuild-plugin-php-manifest');

esbuild.build({
  entryPoints: ['test.js'],
  bundle: true,
  metafile: true, // this is needed to the plugin can generate the manifest
  outdir: './out/',
  plugins: [
    phpManifestPlugin({
      pathPHPManifest: 'manifest.php',
    }),
  ],
});

Plugin Options

The following Plugin Options are available

options.pathPHPManifest

string | undefined Optional Path for the generated PHP Manifest File

options.hash

string | boolean | undefined

If true or undefined it will use the hash provided by esbuild. false will not use a hash and if passed a string it will append the string to the file name.

options.rewriteManifest

Optional function that has the signature rewriteManifest(key: string, value: string): [string, string].

So it gets passed the key (the original file name) and the value (the output) and it should return a tuple [newKey: string, newOuput: string].

options.namePHPManifestClass

Optional Class Name for the generated PHP File, defaults to EsbuildPluginPhpManifest