{"id":13416704,"url":"https://github.com/eusonlito/laravel-Packer","last_synced_at":"2025-03-15T01:31:56.681Z","repository":{"id":19403517,"uuid":"22645275","full_name":"eusonlito/laravel-Packer","owner":"eusonlito","description":"CSS, Javascript and Images packer/processors to Laravel","archived":false,"fork":false,"pushed_at":"2024-03-02T12:41:00.000Z","size":1515,"stargazers_count":60,"open_issues_count":2,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-14T01:22:25.728Z","etag":null,"topics":["compression","css","javascript","laravel","packer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eusonlito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-08-05T13:51:44.000Z","updated_at":"2024-07-22T15:42:55.000Z","dependencies_parsed_at":"2024-06-18T22:48:58.235Z","dependency_job_id":"46e4ccf9-fc42-4f81-82cb-7c87e41b5e96","html_url":"https://github.com/eusonlito/laravel-Packer","commit_stats":{"total_commits":88,"total_committers":4,"mean_commits":22.0,"dds":0.03409090909090906,"last_synced_commit":"7a4d8baa0ca2fc6c4df63a6b44a56323fdb8f023"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Packer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Packer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Packer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eusonlito%2Flaravel-Packer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eusonlito","download_url":"https://codeload.github.com/eusonlito/laravel-Packer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243505895,"owners_count":20301619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","css","javascript","laravel","packer"],"created_at":"2024-07-30T22:00:20.461Z","updated_at":"2025-03-15T01:31:55.923Z","avatar_url":"https://github.com/eusonlito.png","language":"JavaScript","funding_links":[],"categories":["Assets Management"],"sub_categories":[],"readme":"# Laravel \u003e= 5 Packer\n\n[![Build Status](https://travis-ci.org/eusonlito/laravel-Packer.svg?branch=master)](https://travis-ci.org/eusonlito/laravel-Packer)\n[![Latest Stable Version](https://poser.pugx.org/laravel/packer/v/stable.png)](https://packagist.org/packages/laravel/packer)\n[![Total Downloads](https://poser.pugx.org/laravel/packer/downloads.png)](https://packagist.org/packages/laravel/packer)\n[![License](https://poser.pugx.org/laravel/packer/license.png)](https://packagist.org/packages/laravel/packer)\n\nInspired by: https://github.com/ceesvanegmond/minify\n\nWith this package you can pack and minify your existing css and javascript files. This process can be a little tough, this package simplies this process and automates it.\n\nAlso, you can resize/crop images to adapt thumbnails into your layouts.\n\nIf you want a Laravel \u003c= 4.2 compatible version, please use `v4.2` branch.\n\n## Installation\n\nBegin by installing this package through Composer.\n\n```js\n{\n    \"require\": {\n        \"eusonlito/laravel-packer\": \"master-dev\"\n    }\n}\n```\n\n### Laravel installation\n\n```php\n\n// config/app.php\n\n'providers' =\u003e [\n    '...',\n    'Eusonlito\\LaravelPacker\\PackerServiceProvider',\n];\n\n'aliases' =\u003e [\n    '...',\n    'Packer'    =\u003e 'Eusonlito\\LaravelPacker\\Facade',\n];\n```\n\nPublish the config file:\n\n```\nphp artisan vendor:publish --provider=\"Eusonlito\\LaravelPacker\\PackerServiceProvider\"\n```\n\nNow you have a ```Packer``` facade available.\n\n#### CSS\n\n```php\n// resources/views/hello.blade.php\n\n\u003chtml\u003e\n    \u003chead\u003e\n        // Pack a simple file\n        {!! Packer::css('/css/main.css', '/storage/cache/css/main.css') !!}\n\n        // Pack a simple file using cache_folder option as storage folder to packed file\n        {!! Packer::css('/css/main.css', 'css/main.css') !!}\n\n        // Packing multiple files\n        {!! Packer::css(['/css/main.css', '/css/bootstrap.css'], '/storage/cache/css/styles.css') !!}\n\n        // Packing multiple files using cache_folder option as storage folder to packed file\n        {!! Packer::css(['/css/main.css', '/css/bootstrap.css'], 'css/styles.css') !!}\n\n        // Packing multiple files with autonaming based\n        {!! Packer::css(['/css/main.css', '/css/bootstrap.css'], '/storage/cache/css/') !!}\n\n        // pack and combine all css files in given folder\n        {!! Packer::cssDir('/css/', '/storage/cache/css/all.css') !!}\n\n        // pack and combine all css files in given folder using cache_folder option as storage folder to packed file\n        {!! Packer::cssDir('/css/', 'css/all.css') !!}\n\n        // Packing multiple folders\n        {!! Packer::cssDir(['/css/', '/theme/'], '/storage/cache/css/all.css') !!}\n\n        // Packing multiple folders with recursive search\n        {!! Packer::cssDir(['/css/', '/theme/'], '/storage/cache/css/all.css', true) !!}\n\n        // Packing multiple folders with recursive search and autonaming\n        {!! Packer::cssDir(['/css/', '/theme/'], '/storage/cache/css/', true) !!}\n\n        // Packing multiple folders with recursive search and autonaming using cache_folder option as storage folder to packed file\n        {!! Packer::cssDir(['/css/', '/theme/'], 'css/', true) !!}\n    \u003c/head\u003e\n\u003c/html\u003e\n```\n\nCSS `url()` values will be converted to absolute path to avoid file references problems.\n\n#### Javascript\n\n```php\n// resources/views/hello.blade.php\n\n\u003chtml\u003e\n    \u003cbody\u003e\n    ...\n        // Pack a simple file\n        {!! Packer::js('/js/main.js', '/storage/cache/js/main.js') !!}\n\n        // Pack a simple file using cache_folder option as storage folder to packed file\n        {!! Packer::js('/js/main.js', 'js/main.js') !!}\n\n        // Packing multiple files\n        {!! Packer::js(['/js/main.js', '/js/bootstrap.js'], '/storage/cache/js/styles.js') !!}\n\n        // Packing multiple files using cache_folder option as storage folder to packed file\n        {!! Packer::js(['/js/main.js', '/js/bootstrap.js'], 'js/styles.js') !!}\n\n        // Packing multiple files with autonaming based\n        {!! Packer::js(['/js/main.js', '/js/bootstrap.js'], '/storage/cache/js/') !!}\n\n        // pack and combine all js files in given folder\n        {!! Packer::jsDir('/js/', '/storage/cache/js/all.js') !!}\n\n        // pack and combine all js files in given folder using cache_folder option as storage folder to packed file\n        {!! Packer::jsDir('/js/', 'js/all.js') !!}\n\n        // Packing multiple folders\n        {!! Packer::jsDir(['/js/', '/theme/'], '/storage/cache/js/all.js') !!}\n\n        // Packing multiple folders with recursive search\n        {!! Packer::jsDir(['/js/', '/theme/'], '/storage/cache/js/all.js', true) !!}\n\n        // Packing multiple folders with recursive search and autonaming\n        {!! Packer::jsDir(['/js/', '/theme/'], '/storage/cache/js/', true) !!}\n\n        // Packing multiple folders with recursive search and autonaming using cache_folder option as storage folder to packed file\n        {!! Packer::jsDir(['/js/', '/theme/'], 'js/', true) !!}\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### Images\nAll transform options availables at https://github.com/oscarotero/imageCow\n\n```php\n// resources/views/hello.blade.php\n\n\u003chtml\u003e\n    \u003cbody\u003e\n    ...\n        // Set width size to 500px using cache_folder default parameter (from settings)\n        \u003cimg src=\"{{ Packer::img('/images/picture.jpg', 'resize,500') }}\" /\u003e\n\n        // Crop image to 200px square with custom cache folder (full path)\n        \u003cimg src=\"{{ Packer::img('/images/picture.jpg', 'resizeCrop,200,200', '/storage/cache/images/') }}\" /\u003e\n\n        // Crop image to 200px square center middle with custom cache folder (using cache_folder as base)\n        \u003cimg src=\"{{ Packer::img('/images/picture.jpg', 'resizeCrop,200,200', 'images/') }}\" /\u003e\n\n        // Crop image to 200px square center top with custom cache folder (using cache_folder as base)\n        \u003cimg src=\"{{ Packer::img('/images/picture.jpg', 'resizeCrop,200,200,center,top', 'images/') }}\" /\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n### Config\n\n```php\nreturn array(\n\n    /*\n    |--------------------------------------------------------------------------\n    | Current environment\n    |--------------------------------------------------------------------------\n    |\n    | Set the current server environment. Leave empty to laravel autodetect\n    |\n    */\n\n    'environment' =\u003e '',\n\n    /*\n    |--------------------------------------------------------------------------\n    | App environments to not pack\n    |--------------------------------------------------------------------------\n    |\n    | These environments will not be minified and all individual files are\n    | returned\n    |\n    */\n\n    'ignore_environments' =\u003e ['local'],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Public accessible path\n    |--------------------------------------------------------------------------\n    |\n    | Set absolute folder path to public view from web. If you are using\n    | laravel, this value will be set with public_path() function\n    |\n    */\n\n    'public_path' =\u003e realpath(getenv('DOCUMENT_ROOT')),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Asset absolute location\n    |--------------------------------------------------------------------------\n    |\n    | Set absolute URL location to asset folder. Many times will be same as\n    | public_path but using absolute URL. If you are using laravel, this value\n    | will be set with asset() function\n    |\n    */\n\n    'asset' =\u003e 'http://'.getenv('SERVER_NAME').'/',\n\n    /*\n    |--------------------------------------------------------------------------\n    | Base folder to store packed files\n    |--------------------------------------------------------------------------\n    |\n    | If you are using relative paths to second paramenter in css and js\n    | commands, this files will be created with this folder as base.\n    |\n    | This folder in relative to 'public_path' value\n    |\n    */\n\n    'cache_folder' =\u003e '/storage/cache/',\n\n    /*\n    |--------------------------------------------------------------------------\n    | Check if some file to pack have a recent timestamp\n    |--------------------------------------------------------------------------\n    |\n    | Compare current packed file with all files to pack. If exists one more\n    | recent than packed file, will be packed again with a new autogenerated\n    | name.\n    |\n    */\n\n    'check_timestamps' =\u003e true,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Check if you want minify css files or only pack them together\n    |--------------------------------------------------------------------------\n    |\n    | You can check this option if you want to join and minify all css files or\n    | only join files\n    |\n    */\n\n    'css_minify' =\u003e true,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Check if you want minify js files or only pack them together\n    |--------------------------------------------------------------------------\n    |\n    | You can check this option if you want to join and minify all js files or\n    | only join files\n    |\n    */\n\n    'js_minify' =\u003e true,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Use fake images stored in src/images/ when original image does not exists\n    |--------------------------------------------------------------------------\n    |\n    | You can use fake images in your developments to avoid not existing\n    | original images problems. Fake images are stored in src/images/ and used\n    | with a rand\n    |\n    */\n\n    'images_fake' =\u003e true\n);\n```\n\nIf you set the `'check_timestamps'` option, a timestamp value will be added to final filename.\n\n### Using Packer outside Laravel\n\n```php\nrequire (__DIR__.'/vendor/autoload.php');\n\n// Check default settings\n$config = require (__DIR__.'/src/config/config.php');\n\n$Packer = new Eusonlito\\LaravelPacker\\Packer($config);\n\necho $Packer-\u003ecss([\n    '/resources/css/styles-1.css',\n    '/resources/css/styles-2.css'\n], 'css/styles.css')-\u003erender();\n\necho $Packer-\u003ejs('/resources/js/scripts.js', 'js/scripts.js')-\u003erender();\n\necho $Packer-\u003ejs([\n    '/resources/js/scripts-1.js',\n    '/resources/js/scripts-2.js'\n], 'js/')-\u003erender();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feusonlito%2Flaravel-Packer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feusonlito%2Flaravel-Packer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feusonlito%2Flaravel-Packer/lists"}