karelkolaska / nette-assetic
There is no license information available for the latest version (v1.1.1) of this package.
Nette wrapper for kriswallsmith/assetic
v1.1.1
2019-12-08 13:47 UTC
Requires
- php: >=7.1.0
- kriswallsmith/assetic: ^1.4.0
- latte/latte: >=2.4.0
- mrclay/minify: ~2.2.1
- natxet/cssmin: ~3.0.4
- nette/di: >=3.0.0
- nette/utils: >=3.0.0
- oyejorge/less.php: ~1.7.0.10
- patchwork/jsqueeze: ~1.0.7
This package is auto-updated.
Last update: 2022-05-08 19:28:46 UTC
README
Nette extension to manage assets via kriswallsmith/assetic.
Installation
Install KarelKolaska\NetteAssetic using Composer:
$ composer require karelkolaska/nette-assetic
Configuration
Register extension in your NEON configuration:
extensions:
assetic: KarelKolaska\NetteAssetic\DI\AsseticExtension
Set extension configuration:
assetic:
assets:
styles:
output: temp/styles.css
filters: [less, ?cssmin]
files:
- assets/css/style.css
- assets/less/style.less
scripts:
output: temp/scripts.js
filters: [jsmin]
files:
- assets/js/*
Other settings that are not required, and are set by default as below:
Rebuild assets with every hit
parameters:
rebuildAssets: true
DebugMode
assetic:
debug: %debugMode%
Filters
assetic:
filters:
less: Assetic\Filter\LessphpFilter
cssmin: Assetic\Filter\CssMinFilter
jsmin: Assetic\Filter\JSMinFilter
Workers
assetic:
workers:
# place to register your workers
Usage
In template with macro assets:
{assets styles, scripts}
Macro save assets output to temp folder and generates HTML:
<link rel="stylesheet" href="/temp/styles.css?v=1525856452" />
<script type="text/javascript" src="/temp/scripts.js?v=1524029735" /></script>
Example of generating assets on deploy
Symphony console command to generate assets:
use Assetic\AssetManager;
use Assetic\AssetWriter;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class AssetsBuildCommand extends Command
{
/** @var string */
protected static $defaultName = 'assets:build';
/** @var AssetWriter @inject */
public $assetWriter;
/** @var AssetManager @inject */
public $assetManager;
/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output): void
{
$this->assetWriter->writeManagerAssets($this->assetManager);
}
}
License
This project is licensed under the MIT License - see the LICENSE.md file for details.