Skip to content

Makes it easy to get the filename outputted by webpack just by specifying the name of the chunk and filetype(CSS/JS).

Notifications You must be signed in to change notification settings

alexskra/simple-php-manifest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

simple-php-manifest

Makes it easy to get the filename outputted by webpack just by specifying the name of the chunk and filetype(CSS/JS).

Getting Started

First, you'll need to install simple-php-manifest:

npm install --save-dev simple-php-manifest

Then, add the plugin to your webpack config.

Options

Name Type Default Description
className String SimplePhpManifest Wanted name of the created class
namespace String no namespace What namespace the class should use, default is none.
outputDir String ./ Where to output the created class

Example of created PHP class

<?php

/**
 * Class SimplePhpManifest
 *
 * Generated by simple-php-manifest Used to get the filenames outputted by webpack.
 * @author alexskra.com
 */
class SimplePhpManifest
{
    /**
     * Contains a list of CSS and JS assets.
     *
     * @var array
     */
    protected static $assets = [
        'js' => [
            'main' => 'js/main.js',
        ],
        'css' => [
            'style' => 'css/style.css',
        ]
    ];

    /**
     * Gets the JS filename by chunkName.
     *
     * @param string $chunkName
     * @return string
     */
    public static function js(string $chunkName): string
    {
        return self::$assets['js'][$chunkName];
    }

    /**
     * Gets the CSS filename by chunkName.
     *
     * @param string $chunkName
     * @return string
     */
    public static function css(string $chunkName): string
    {
        return self::$assets['css'][$chunkName];
    }
}

Sample usage:

<?= SimplePhpManifest::js('main') ?>

About

Makes it easy to get the filename outputted by webpack just by specifying the name of the chunk and filetype(CSS/JS).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published