bicisteadm / webloader-reload
Tool for loading or deploying CSS and JS files into web pages
Installs: 29 436
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 84
Open Issues: 1
Requires
- php: >= 7.1
- ext-json: *
- nette/application: ^3.0
- nette/di: ^3.0
- nette/utils: ^3.0
Requires (Dev)
- jakub-onderka/php-parallel-lint: ~0.7
- kylekatarnls/coffeescript: 1.3.*
- latte/latte: ^2.5
- leafo/scssphp: ^0.7
- mockery/mockery: 1.*
- nette/application: ^3.0
- nette/bootstrap: ^3.0
- nette/caching: ^3.0
- nette/component-model: ^3.0
- nette/database: ^3.0
- nette/deprecated: ^2.3
- nette/di: ^3.0
- nette/finder: ^2.5
- nette/forms: ^3.0
- nette/http: ^3.0
- nette/mail: ^3.0
- nette/neon: ^3.0
- nette/php-generator: ^3.0
- nette/reflection: ^2.4
- nette/robot-loader: ^3.0
- nette/safe-stream: ^2.4
- nette/security: ^3.0
- nette/tokenizer: ^3.0
- nette/utils: ^3.0
- oyejorge/less.php: ^1.7
- phpstan/phpstan-nette: ^0.11.0
- phpstan/phpstan-shim: ^0.11.0
- phpunit/phpunit: 7.*
- tracy/tracy: ^2.6
Suggests
- coffeescript/coffeescript: CoffeeScript compiler written in PHP.
- joseki/webloader-filters: CSSMin & JSMin filters written in PHP.
- leafo/scssphp: SCSS compiler written in PHP.
- oyejorge/less.php: LESS compiler written in PHP.
README
Component for CSS and JS files loading
WebLoader-Reload is an updated WebLoader package by janmarek for the latest version of Nette (Nette-3.0). Also contains some bug fixes.
Big thanks to Gappa, who updated the package for Nette-3.0.
Author: Jan Marek Licence: MIT
Example
Control factory in Nette presenter:
<?php protected function createComponentCss() { $files = new WebLoader\FileCollection(WWW_DIR . '/css'); $files->addFiles(array( 'style.css', WWW_DIR . '/colorbox/colorbox.css', )); $files->addWatchFiles(Finder::findFiles('*.css', '*.less')->in(WWW_DIR . '/css')); $compiler = WebLoader\Compiler::createCssCompiler($files, WWW_DIR . '/temp'); $compiler->addFilter(new WebLoader\Filter\VariablesFilter(array('foo' => 'bar'))); $compiler->addFilter(function ($code) { return cssmin::minify($code, "remove-last-semicolon"); }); $control = new WebLoader\Nette\CssLoader($compiler, '/webtemp'); $control->setMedia('screen'); return $control; }
Template:
{control css}
Example with Nette Framework extension used
Configuration in app/config/config.neon
:
extensions: webloader: WebLoader\Nette\Extension services: wlCssFilter: WebLoader\Filter\CssUrlsFilter(%wwwDir%) lessFilter: WebLoader\Filter\LessFilter jwlCssMinFilter: Joseki\Webloader\CssMinFilter webloader: css: default: files: - style.css - {files: ["*.css", "*.less"], from: %appDir%/presenters} # Nette\Utils\Finder support filters: - @jwlCssMinFilter fileFilters: - @lessFilter - @wlCssFilter watchFiles: # only watch modify file - {files: ["*.css", "*.less"], from: css} - {files: ["*.css", "*.less"], in: css} js: default: remoteFiles: - http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js - http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js files: - %appDir%/../libs/nette/nette/client-side/netteForms.js - web.js
For older versions of Nette, you have to register the extension in app/bootstrap.php
:
$webloaderExtension = new \WebLoader\Nette\Extension(); $webloaderExtension->install($configurator);
Usage in app/presenters/BasePresenter.php
:
/** @var \WebLoader\Nette\LoaderFactory @inject */ public $webLoader; /** @return \WebLoader\Nette\CssLoader */ protected function createComponentCss() { return $this->webLoader->createCssLoader('default'); } /** @return \WebLoader\Nette\JavaScriptLoader */ protected function createComponentJs() { return $this->webLoader->createJavaScriptLoader('default'); }
Template:
{control css} {control js}