oriceon / minify
用于laravel 6+压缩样式和javascript的包
2.0.0
2024-03-16 11:35 UTC
Requires
- php: >=7.2
- illuminate/filesystem: ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- natxet/cssmin: 3.*
- tedivm/jshrink: 1.4.0
Requires (Dev)
- mikey179/vfsstream: 1.6.*
- phpspec/phpspec: 2.0.0
This package is auto-updated.
Last update: 2024-09-16 12:37:03 UTC
README
使用此包,您可以压缩laravel 6+中现有的样式表和javascript文件。这个过程可能有点困难,此包简化了这个过程并实现了自动化。
安装
首先通过Composer安装此包。
composer require oriceon/minify
发布配置文件
php artisan vendor:publish --provider="Oriceon\Minify\MinifyServiceProvider" --force
包会自动发现,您可以在应用程序的任何地方使用此外观
样式表
// app/views/hello.blade.php <html> <head> ... {!! Minify::stylesheet('/css/main.css') !!} // or by passing multiple files {!! Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css')) !!} // add custom attributes {!! Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css'), array('foo' => 'bar')) !!} // add full uri of the resource {!! Minify::stylesheet(array('/css/main.css', '/css/bootstrap.css'))->withFullUrl() !!} {!! Minify::stylesheet(array('//fonts.googleapis.com/css?family=Roboto')) !!} // minify and combine all stylesheet files in given folder {!! Minify::stylesheetDir('/css/') !!} // add custom attributes to minify and combine all stylesheet files in given folder {!! Minify::stylesheetDir('/css/', array('foo' => 'bar', 'defer' => true)) !!} // minify and combine all stylesheet files in given folder with full uri {!! Minify::stylesheetDir('/css/')->withFullUrl() !!} </head> ... </html>
JavaScript
// app/views/hello.blade.php <html> <body> ... </body> {!! Minify::javascript('/js/jquery.js') !!} // or by passing multiple files {!! Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js')) !!} // add custom attributes {!! Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js'), array('bar' => 'baz')) !!} // add full uri of the resource {!! Minify::javascript(array('/js/jquery.js', '/js/jquery-ui.js'))->withFullUrl() !!} {!! Minify::javascript(array('//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js')) !!} // minify and combine all javascript files in given folder {!! Minify::javascriptDir('/js/') !!} // add custom attributes to minify and combine all javascript files in given folder {!! Minify::javascriptDir('/js/', array('bar' => 'baz', 'async' => true)) !!} // minify and combine all javascript files in given folder with full uri {!! Minify::javascriptDir('/js/')->withFullUrl() !!} </html>