Files
thetool/public/bundler.php
2025-07-23 20:44:25 +02:00

62 lines
2.1 KiB
PHP

<?php
include 'JSShrink.php';
// Set the content type to JavaScript
header('Content-Type: application/javascript');
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
function combineAndMinifyJS($files) {
$combinedContent = '';
foreach ($files as $file) {
if (file_exists($file)) {
$content = file_get_contents($file);
// Minify using JSShrink
$content = \JShrink\Minifier::minify($content);
$combinedContent .= $content . "\n";
} else {
header("HTTP/1.1 404 Not Found");
echo "File not found: $file";
exit;
}
}
return $combinedContent;
}
$jsFiles = [
"plugins/axios/axios.min.js",
"plugins/axios/axios.inject.js",
"plugins/moment/moment.min.js",
"plugins/daterangepicker/daterangepicker.js",
"plugins/vue/" . (isset($_GET['VUE_DEBUG']) || $_SERVER['HTTP_HOST'] === "localhost" ? "vue.js" : "vue.min.js"),
"plugins/vue/tt-components/tt-button.js",
"plugins/vue/tt-components/tt-card.js",
"plugins/vue/tt-components/tt-table.js",
"plugins/vue/tt-components/tt-table-crud.js",
"plugins/vue/tt-components/tt-page-title.js",
"plugins/vue/tt-components/tt-loader.js",
"plugins/vue/tt-components/tt-select.js",
"plugins/vue/tt-components/tt-datepicker.js",
"plugins/vue/tt-components/tt-input.js",
"plugins/vue/tt-components/tt-input-article.js",
"plugins/vue/tt-components/tt-button.js",
"plugins/vue/tt-components/tt-modal.js",
"plugins/vue/tt-components/tt-autocomplete.js",
"plugins/vue/tt-components/tt-icon-select.js",
"plugins/vue/tt-components/tt-number-range.js",
"plugins/vue/tt-components/tt-checkbox.js",
"plugins/vue/tt-components/tt-textarea.js",
"plugins/vue/tt-components/tt-position-manager.js",
"plugins/vue/tt-components/tt-tooltip.js",
"plugins/vue/tt-components/tt-map.js",
"plugins/vue/tt-components/tt-file-gallery.js",
];
// Output the combined and minified JavaScript
$minified = combineAndMinifyJS($jsFiles);
echo $minified;
?>