kapoko / asset-json-reader
Reads asset locations from a json file outputted by webpack
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/kapoko/asset-json-reader
Requires
- symfony/filesystem: ^5.2
This package is auto-updated.
Last update: 2025-10-09 18:25:30 UTC
README
Reads asset locations from a json file outputted by webpack. Works well with asset-webpack-plugin or webpack-manifest-plugin, which stores the hashed filenames in a json file. With this package you can easily get the hashed filenames
Install
composer require kapoko/asset-json-reader:dev-main
Usage
Output by the asset-webpack-plugin may look something like this (dist/assets.json
):
{ "one": { "js": "/js/one_2bb80372ebe8047a68d4.bundle.js" }, "two": { "js": "/js/two_2bb80372ebe8047a68d4.bundle.js" } }
Usage is:
use Kapoko\AssetJsonReader\AssetJsonReader; $assets = new AssetJsonReader($pathToJson); $assets->get('one.js')); // Returns '/js/one_2bb80372ebe8047a68d4.bundle.js' $assets->get('two.js')); // Returns '/js/two_2bb80372ebe8047a68d4.bundle.js'
If the manifest doesn't exists it returns the given string, which might be handy in development mode when the files aren't hashed.