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

@visto9259/php-webpack-plugin

v1.1.0

Published

A PHP webpack plugin to generate a file containing a PHP associative array manifest

Downloads

30

Readme

PHP Webpack Plugin

This module will work only with Webpack 4 and above.

This Webpack plugin will create a PHP file in your output.path directory containing an associative arrays of entry points and their corresponding chunk groups.

The resulting file can be used by your PHP application to determine which files should be included when rendering your frontend of your website.

The resulting PHP file will have the following format:

<?php
return [
    'entry1' => [
        'chunk1.js' => '{publicPath}/asset1.js',
        'chunk2.js => '{publicPath}/asset2.js',
        // ... more chunks for 'entry1'
    ],
    'entry2' => [
        'chunk1.js' => '{publicPath}/asset1.js',
        'chunk2.js => '{publicPath}/asset2.js',
        // ... more chunks for entry2
    ]
];

In a ZendFramework or Laminas MVC application, this file can be used to load the scripts associated with a given rendered page by associating templates or matched routes to a given entry point.

(An example application will come later)

Companion Zend and Laminas framework modules are in the works to automate the rendering of script tags using the output of this plugin.

Install

Using NPM

$ npm install @visto9259/php-webpack-plugin

Using Yarn

$ yarn add @visto9259/php-webpack-plugin

Usage

// in your webpack config file

const PhpWebpackPlugin = require('php-webpack-plugin');

module.exports = {
    // ...
    plugins: [
        new PhpWebpackPlugin(options)
    ]
}

Available Options

filename (default: "scriptlists.php")

The filename that will contain the associative array. The file will be created in the directory set by output.path and will be appended with .php if no extension is set.

entryPoint (default: null)

The name of the entry point in the webpack configuration for which to create a script. If not set, then all the entry points are processed.

For example, considering the following webpack config:

const PhpWebpackPlugin = require('php-webpack-plugin');

module.exports = {
    entry: {
        main: 'index.js',
        print: 'print.js,
    },
    plugins: [
        new PhpWebpackPlugin({
        }),
        new PhpWebpackPlugin({
            entryPoint: 'print'
            filename: 'print'
        }),
    ]
} 

then 2 PHP files will be created:

scriptlist.php from the first instance of the plugin:

<?php
return [
    'main' => [
        'index.js' => '{publicPath}/index.js',
        'chunk2.js => '{publicPath}/chunk2.js',
        // ... more chunks
    ],
    'print' => [
        'print.js' => '{publicPath}/index.js'
        'chunk2.js => '{publicPath}/chunk2.js',
        // ... more chunks
    ]
];

print.php from the second instance of the plugin:

<?php
return [
    'print' => [
        'print.js' => '{publicPath}/index.js'
        'chunk2.js => '{publicPath}/chunk2.js',
        // ... more chunks
    ]
];

Future versions

I want this plugin to evolve. Ideas for future versions:

  • Add templating capability for more control on the content of the output file
  • Add hooks to extend processing using other plugins

Issues

This is a new package. Probably not free of bugs. Please raise issues and questions in the issues section.