/** * Simple connection to the asset pipeline module. * returns/parses a url to the assets specified in array and option which will be handled by the * responsible pipe if the asset pipeline itself is loaded as a module during the request. * * Note: If the asset pipeline is inactive the call-routing can only handle a string! * * @param array|array $assets containing asset(s) as in ['jquery.js', 'myplugin.js'] (will be concatenated) * @param array $options for asset pipeline (path and other) defaults to ['min'] for asset minification in prod-mode and nulled path * * @return string the URI to the requested asset(s) */ public static function assets($assets, $options = []) { # Determines pipe by last file's extension, different files in one request is madness $pipe = pathinfo($assets[count($assets) - 1], PATHINFO_EXTENSION); $assets = implode("+", $assets); if (AssetPipeline::getConfig()['stage'] === 'prod') { $options[] = 'min'; } # Return the url with its options return LVC::get()->url('asset-pipeline::' . $pipe, array_merge($options, array($assets))); }
public static function configure($assetRootDirectory) { assetpipes\CssPipe::register('css', ['min']); assetpipes\SassPipe::register('scss', ['min']); assetpipes\LessPipe::register('less', ['min']); assetpipes\JsPipe::register('js', ['min']); assetpipes\CoffeescriptPipe::register('coffee', ['min']); assetpipes\FontPipe::register('font', ['']); assetpipes\MarkdownPipe::register('markdown', ['']); assetpipes\ImagePipe::register('img', [LVC::get()->request->w, LVC::get()->request->h]); controllers\AssetPipeline::registerFlexOptions([LVC::get()->request->w => LVC::get()->request->w, LVC::get()->request->h => LVC::get()->request->h]); controllers\AssetPipeline::configure($assetRootDirectory); }
/** * Registers pipe at controller based on its pipe type. * * @param array $type to be registered upon which pipe will get notified (e.g. css) also defines * controller path (e.g. assetpipe/css/styles.css) */ public static function register($type, $options = []) { #late static binding goodness controllers\AssetPipeline::registerAssetpipe($type, get_called_class(), $options); }