improved performance of vue modules
This commit is contained in:
53
public/cssbundler.php
Normal file
53
public/cssbundler.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
// Set the content type to CSS
|
||||
header('Content-Type: text/css');
|
||||
header('Cache-Control: max-age=31536000, public'); // Cache for 1 year
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); // Expires in 1 year
|
||||
|
||||
/**
|
||||
* Combines and minifies an array of CSS files.
|
||||
*
|
||||
* @param array $files An array of CSS file paths.
|
||||
* @return string The combined and minified CSS content.
|
||||
*/
|
||||
function combineAndMinifyCSS($files) {
|
||||
// Create a new Minify\CSS instance
|
||||
$minifier = new \MatthiasMullie\Minify\CSS();
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (file_exists($file)) {
|
||||
// Add the file's content to the minifier
|
||||
$minifier->add($file);
|
||||
} else {
|
||||
// Handle missing files gracefully
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
echo "/* File not found: $file */";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the minified content
|
||||
return $minifier->minify();
|
||||
}
|
||||
|
||||
// Define the array of CSS files to be combined and minified
|
||||
$cssFiles = [
|
||||
'plugins/daterangepicker/daterangepicker.css',
|
||||
'assets/css/bootstrap.min.css',
|
||||
'assets/css/app.min.css',
|
||||
'plugins/notification/notify.min.css',
|
||||
'assets/css/thetool.css',
|
||||
'plugins/vue/tt-components/css/tt-table.css',
|
||||
'plugins/vue/tt-components/css/tt-tooltip.css',
|
||||
'plugins/vue/tt-components/css/tt-loader.css',
|
||||
'plugins/vue/tt-components/css/tt-file-gallery.css',
|
||||
'plugins/vue/tt-components/css/tt-position-manager.css',
|
||||
];
|
||||
|
||||
// Output the combined and minified CSS
|
||||
echo combineAndMinifyCSS($cssFiles);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user