Plan: Add External JS Minification Tool Support 1. Configuration Structure Add a new [tools] section to the page config to specify external minification tools: [tools] # External minification tools (optional) js_minifier = "terser" # terser, uglifyjs, esbuild, swc, or path to custom tool js_minifier_path = "/usr/local/bin/terser" # Optional: explicit path js_minifier_args = ["--compress", "--mangle"] # Optional: custom arguments css_minifier = "" # Future: similar for CSS html_minifier = "" # Future: similar for HTML 2. Framework Changes A. Update framework/templates/page.config.toml.template - Add the [tools] section with sensible defaults - Document available minifiers and their options B. Update framework/core/framework-utils.nu - Add tool configuration extraction from page config - Handle optional tool paths and arguments C. Enhance framework/optimizers/optimize-js.nu - Add minify_js_with_tool function that: - Checks if external tool is configured - Validates tool availability - Falls back to built-in minification if tool not found - Handles tool execution with proper error handling D. Update framework/core/build.nu - Modify the JS build process to check for external tools - Use external tool for production/staging builds - Keep built-in minification for development or as fallback 3. Tool Detection & Fallback Strategy # Pseudo-code for tool selection if $config.tools.js_minifier and not $dev { if (check_tool_available $config.tools.js_minifier) { use external_minifier } else { print warning "Tool not found, using built-in minifier" use built_in_minifier } } else { use built_in_minifier } 4. Supported Tools Initially support these popular JS minifiers: - terser - Modern JS minifier (npm install -g terser) - uglifyjs - Classic JS minifier (npm install -g uglify-js) - esbuild - Fast bundler/minifier (npm install -g esbuild) - swc - Rust-based fast minifier (npm install -g @swc/cli @swc/core) 5. Example Usage Pages that need advanced JS minification can configure: [tools] js_minifier = "terser" js_minifier_args = ["--compress", "drop_console=true", "--mangle", "--toplevel"] 6. Benefits - Professional-grade minification for production - Configurable per page or globally - Graceful fallback to built-in minifier - Support for different tools based on project needs - Future extensibility for CSS and HTML tools