WIP: VERSION: 03.07.00 > Link asset minification to Joomla cache system #62

Closed
Copilot wants to merge 15 commits from copilot/update-css-js-minification into dev/03.07.00
2 changed files with 17 additions and 2 deletions
Showing only changes of commit 714a3f44a1 - Show all commits

View File

@@ -21,6 +21,18 @@ defined('_JEXEC') or die;
* *
* Handles minification and cleanup of CSS and JavaScript assets * Handles minification and cleanup of CSS and JavaScript assets
* based on the development mode setting. * based on the development mode setting.
*
* IMPORTANT NOTES:
* - This is a BASIC minifier suitable for development/production switching
* - For production builds, consider using professional tools like:
* * CSS: cssnano, clean-css
* * JavaScript: terser, uglify-js, closure-compiler
* - URL preservation in JS is best-effort; complex cases may fail
* - String content preservation is basic; edge cases may exist
* - Does not handle complex string scenarios or regex patterns
*
* The minifier is designed to be "good enough" for automatic switching
* between development and production modes, not for optimal compression.
*/ */
class AssetMinifier class AssetMinifier
{ {
@@ -167,6 +179,9 @@ class AssetMinifier
$result['deleted'] = self::deleteMinifiedFiles($mediaPath); $result['deleted'] = self::deleteMinifiedFiles($mediaPath);
} else { } else {
// Create minified versions of CSS and JS files // Create minified versions of CSS and JS files
// NOTE: This list is hardcoded for predictability and to ensure only
// specific template files are minified. Vendor files are excluded as
// they come pre-minified. If you add new template assets, add them here.
$files = [ $files = [
'css/template.css' => 'css/template.min.css', 'css/template.css' => 'css/template.min.css',
'css/user.css' => 'css/user.min.css', 'css/user.css' => 'css/user.min.css',

View File

@@ -133,8 +133,8 @@ try {
// Scripts // Scripts
$wa->useScript('template.js' . $assetSuffix); $wa->useScript('template.js' . $assetSuffix);
$wa->useScript('theme-init' . $assetSuffix . '.js'); $wa->useScript('theme-init.js' . $assetSuffix);
$wa->useScript('darkmode-toggle' . $assetSuffix . '.js'); $wa->useScript('darkmode-toggle.js' . $assetSuffix);
$wa->useScript('vendor.bootstrap-toc.js' . $assetSuffix); $wa->useScript('vendor.bootstrap-toc.js' . $assetSuffix);
// Font scheme (external or local) + CSS custom properties // Font scheme (external or local) + CSS custom properties