Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crypto-scythe/bundledassets
A Laminas view helper for adding JavaScript and CSS assets created by bundlers
https://github.com/crypto-scythe/bundledassets
Last synced: 11 days ago
JSON representation
A Laminas view helper for adding JavaScript and CSS assets created by bundlers
- Host: GitHub
- URL: https://github.com/crypto-scythe/bundledassets
- Owner: crypto-scythe
- License: mit
- Created: 2021-08-06T20:45:08.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-07T20:09:07.000Z (over 3 years ago)
- Last Synced: 2024-04-30T00:20:58.885Z (8 months ago)
- Language: PHP
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# crypto_scythe/bundledassets
[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs)
[![Run unit tests](https://github.com/crypto-scythe/bundledassets/actions/workflows/run-unit-tests.yaml/badge.svg?branch=master)](https://github.com/crypto-scythe/bundledassets/actions/workflows/run-unit-tests.yaml)A Laminas view helper for adding JavaScript and CSS assets created by bundlers.
## Installation
### Composer
```shell
composer require crypto_scythe/bundledassets
```### Manual
You can download the [latest release zip file](https://github.com/crypto-scythe/bundledassets/releases/latest)
and unpack it into a own module folder. Please make sure to install the dependencies
outlined in the composer.json for it to work correctly.## Usage/Examples
### Laminas MVC
```php
# Add module class to Modules configuration
CryptoScythe\BundledAssets\Module::class,
```### Laminas Mezzio
```php
# Add config provider class to configuration
CryptoScythe\BundledAssets\ConfigProvider::class,
```### Configuration
```php
# global.php
use CryptoScythe\BundledAssets\ConfigProvider as BundledAssetsConfigProvider;BundledAssetsConfigProvider::GLOBAL_CONFIG_KEY_VIEW_HELPER_CONFIG => [
BundledAssetsConfigProvider::class => [
BundledAssetsConfigProvider::CONFIG_KEY_CACHE_PATH => 'data/bundled_assets_cache.php', # Path to cache file, mostly production
BundledAssetsConfigProvider::CONFIG_KEY_MANIFESTS => [ # Hash map of manifest files
BundledAssetsConfigProvider::CONFIG_KEY_DEFAULT_MANIFEST => 'data/webpack-assets.json',
'other_manifest' => 'data/other-assets.json', # [optional] You can use multiple asset manifests
],
],
],
```### Usage in layout
```php
$this->bundledAssets('entry_point'); # Uses assets from default
$this->bundledAssets('some_other_entry_point', 'other_manifest'); # Uses additionally defined manifest
```## FAQ
### What is a manifest file?
A manifest file contains a list of the bundled assets, for example the output of
[assets-webpack-plugin](https://www.npmjs.com/package/assets-webpack-plugin).It looks something like this:
```php
{
"main": {
"js": [
"some_js_asset.12345.js",
"some_other_js_asset.54321.js"
],
"css": [
"some_css_asset.12345.css",
"another_css_asset.abcdef.css"
],
},
"another": {
# even more of the same
}
}
```## Author
- Chris Fasel [@crypto-scythe](https://www.github.com/crypto-scythe)
## License
[MIT](https://choosealicense.com/licenses/mit/)