adambisek/gulp-assets

v1.1.0 2016-06-03 08:32 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:42:06 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version License

该组件旨在与Nette框架一起使用。当您使用gulp处理资源时,您不再需要Webloader。只需将gulp处理后的资源链接到页面。将文件哈希添加到查询字符串中,以强制在gulp处理新文件后刷新。

安装

首选的安装方法是使用 Composer

composer require adambisek/gulp-assets

使用

config.neon -> 简单定义输出gulp文件并定义工厂服务

parameters:
	assetsFactory:
		basePath: '%appDir%/../public'
		front:
			css:
				dist/front/front.bundle.css: all
				dist/front/front-print.bundle.css: all
			js:
				- dist/front/front.bundle.js

services:
	- GulpAssets\ControlFactory(%assetsFactory%)

BasePresenter -> 使用工厂服务创建可渲染的组件

public function createComponentCss()
{
	return $this->assetsControlFactory->createCssControl('front');
}

public function createComponentJs()
{
	return $this->assetsControlFactory->createJsControl('front');
}

模板 (Latte)

<html>
	<head>
		{control js}
		{control css}
	</head>
	<body> ... </body>
</html>