laravite / manifest
Framework-agnostic library for parsing Vite manifest files
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: ^8.1
Requires (Dev)
- ergebnis/composer-normalize: ^2.23
- opis/json-schema: ^2.3
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5.18
Suggests
- opis/json-schema: Allows validating the Vite manifest against a JSON schema
This package is auto-updated.
Last update: 2023-04-28 20:02:18 UTC
README
Manifest is a framework-agnostic PHP library for parsing Vite manifest files.
Installation
Manifest is distributed via Packagist and can be installed with Composer.
composer require laravite/manifest
Usage
Manifest is straightforward to use.
// Parse a JSON-encoded manifest $manifest = Manifest::parse($json); // Retrieve entries $allEntries = $manifest->entries; $mainEntry = $manifest->entry('main.js'); // Retrieve chunks $allChunks = $manifest->chunks; $mainChunk = $manifest->chunk('main.js');
Chunk
objects expose the following properties file
, isEntry
, isDynamicEntry
,
src
, css
, assets
, imports
, dynamicImports
. Most of these properties are actually
optional, and will return null
if they are not present on the chunk.
If the chunks of the parsed manifest contain additional fields, they will also be exposed
on the Chunk
object. This make Manifest compatible with plugins that extend the original
manifest file.
Manifest validation
Manifest can optionally validate the Vite manifest against its JSON schema to ensure
that it is valid. To enable validation, install the suggested opis/json-schema
package and
pass true
to the validate
parameter.
$manifest = Manifest::parse($json, validate: true);
License
Manifest is open-sourced software licensed under the MIT license.