Skip to content

danielkurecka/nette-webpack-manifest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webpack Manifest Extension for Nette Framework

This is a simple extension designed to read Webpack assets from a manifest file generated by the webpack-manifest-plugin. It adds two functions, getWebpackAsset() and hasWebpackAsset() to Latte templates. This extension only reads values from the manifest file, so you should ensure that the proper path is generated in the manifest file. When debug mode is enabled, assets are always read from the manifest file. When debug mode is disabled, assets are cached in the DI container.

Installation

composer require daku/nette-webpack-manifest

Usage

To use this extension, register it and provide the path to the manifest file in your Neon configuration file:

extensions:
	webpackManifest: Daku\Nette\Webpack\WebpackManifestExtension('%wwwDir%/static/webpack/manifest.json')

You can then use the getWebpackAsset() function to retrieve the asset path. If the asset is not found, an exception is thrown. You can also check for the existence of an asset using the hasWebpackAsset() function:

<link rel="stylesheet" n:if="hasWebpackAsset('app.css')" href="{$basePath}/{getWebpackAsset('app.css')}">
<script n:if="hasWebpackAsset('app.js')" src="{$basePath}/{getWebpackAsset('app.js')}"></script>

Requirements

  • PHP >= 8.0
  • Nette >= 3

About

Provides Latte functions for reading asset paths from Webpack manifest file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages