freshheads / webpack-bundle
A Symfony bundle to create paths to webpack assets in your Twig templates.
Installs: 56 998
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 8
Forks: 7
Open Issues: 2
Type:symfony-bundle
Requires
- php: >=7.4
- freshheads/webpack-stats: ^2.0
- symfony/asset: ^5.4 | ^6.0
- symfony/config: ^5.4 | ^6.0
- symfony/dependency-injection: ^5.4 | ^6.0
- symfony/event-dispatcher: ^5.4 | ^6.0
- symfony/http-kernel: ^5.4 | ^6.0
- symfony/templating: ^5.4 | ^6.0
- symfony/twig-bundle: ^5.4 | ^6.0
- symfony/yaml: ^5.4 | ^6.0
- twig/twig: ^2.0 | ^3.0
Requires (Dev)
- symfony/phpunit-bridge: ^5.4 | ^6.0
README
A Symfony bundle to create paths to webpack assets in your Twig templates. This bundle uses the webpack statistics file to find the newest assets for a given webpack entry.
Installation
Install with composer:
composer require freshheads/webpack-bundle
Register the bundle
// config/bundles.php return [ // ... FH\Bundle\WebpackBundle\FHWebpackBundle::class => [ 'all' => true ] ];
Configuration
All configuration options, with default values:
fh_webpack: stats_filename: stats.json # web/document root, assets will be referenced from this path web_dir: '%kernel.project_dir%/web'
Usage
Link webpack files
<link rel="stylesheet" href="{{ webpack_asset('assets/frontend/build', 'app', 'css') }}" /> <script type="text/javascript" src="{{ webpack_asset('assets/frontend/build', 'app', 'js') }}"></script>
Dump the contents of a webpack file
<style type="text/css"> {{ webpack_asset_contents('assets/frontend/build', 'email', 'css')|raw }} </style>
Requirements
This library works with PHP 7.4 and up.