### Install Compress Integration using NPM Source: https://github.com/playform/compress/blob/Current/README.md Use the `astro add` command with NPM to install the Compress integration and automatically configure your project. ```bash npx astro add @playform/compress ``` -------------------------------- ### Install Compress Integration Dependencies Manually Source: https://github.com/playform/compress/blob/Current/README.md Manually install the Compress integration as a development dependency using NPM. ```bash npm install -D -E @playform/compress ``` -------------------------------- ### Install Compress Integration using PNPM Source: https://github.com/playform/compress/blob/Current/README.md Use the `astro add` command with PNPM to install the Compress integration and automatically configure your project. ```bash pnpx astro add @playform/compress ``` -------------------------------- ### Install Compress Integration using Yarn Source: https://github.com/playform/compress/blob/Current/README.md Use the `astro add` command with Yarn to install the Compress integration and automatically configure your project. ```bash yarn astro add @playform/compress ``` -------------------------------- ### Initialize Theme and Display Source: https://github.com/playform/compress/blob/Current/docs/hierarchy.html Sets the document theme based on local storage or OS preference and controls initial body display behavior with a timeout. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display="none"; setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500) ``` -------------------------------- ### Configure Multiple Input-Output Path Mappings Source: https://github.com/playform/compress/blob/Current/docs/index.html Combine multiple path configurations, including individual directories and input-output maps, for comprehensive compression control. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Path: [ // Compress Target "./Target", // Compress Target one more time into a different directory new Map([["./Target", "./TargetCompress"]]), ], }), ], }; ``` -------------------------------- ### Action Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Action pipe configuration. ```APIDOC ## Action Option ### Description Action pipe configuration. ### Type `boolean | Interface` ``` -------------------------------- ### Interface Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CLI.Interface.html The main Interface function processes files and optionally compresses them. It returns a Promise that resolves when the operation is complete. ```APIDOC ## Interface ### Description Processes an array of files and optionally compresses them. Returns a Promise that resolves with no value upon completion. ### Method (Implicitly a function call, not an HTTP method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **File** (string[]) - Required - An array of file paths to process. * **Compress** (string) - Optional - A parameter related to compression, its specific function is not detailed. ### Returns * [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise) ### Request Example ```javascript // Example usage (assuming 'Interface' is imported and available) // Interface(['path/to/file1.txt', 'path/to/file2.txt'], 'some_compression_option'); ``` ### Response #### Success Response * void - The promise resolves when the operation is finished. #### Response Example ```json // No specific response body is returned, the promise resolves. ``` ``` -------------------------------- ### Image Sharp Interface Options Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Image_sharp.Interface.html The Interface defines optional configurations for various image formats and general sharp processing. Each format can be enabled with a boolean or specific options. ```APIDOC ## Interface: Image/sharp.Interface ### Description Defines the configuration options for image processing using the sharp library. This interface allows for granular control over various image formats like AVIF, GIF, HEIF, JPEG, PNG, TIFF, and WebP, as well as general sharp processing options. ### Properties - **avif?** (boolean | AvifOptions) - Optional. Enables AVIF format support or provides specific AVIF compression options. - **gif?** (boolean | GifOptions) - Optional. Enables GIF format support or provides specific GIF compression options. - **heif?** (boolean | HeifOptions) - Optional. Enables HEIF format support or provides specific HEIF compression options. - **jpeg?** (boolean | JpegOptions) - Optional. Enables JPEG format support or provides specific JPEG compression options. - **png?** (boolean | PngOptions) - Optional. Enables PNG format support or provides specific PNG compression options. - **tiff?** (boolean | TiffOptions) - Optional. Enables TIFF format support or provides specific TIFF compression options. - **webp?** (boolean | WebpOptions) - Optional. Enables WebP format support or provides specific WebP compression options. - **sharp?** (boolean | SharpOptions) - Optional. Enables general sharp processing options. - **[key: string]?** (boolean | AvifOptions | GifOptions | HeifOptions | JpegOptions | PngOptions | SharpOptions | TiffOptions | WebpOptions | undefined) - Allows for additional, dynamically defined options. ### Indexable Properties - **[key: string]** (boolean | AvifOptions | GifOptions | HeifOptions | JpegOptions | PngOptions | SharpOptions | TiffOptions | WebpOptions | undefined) - This property allows for any string key to be used, mapping to a boolean, specific format options, or undefined. ### Source Defined in Application/PlayForm/NPM/Compress/Source/Interface/Image/sharp.ts:16 ``` -------------------------------- ### Input-Output Directory Mapping Source: https://github.com/playform/compress/blob/Current/README.md Use a Map to define specific input-to-output directory mappings for compression. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Path: new Map([["./Source", "./Target"]]), }), ], }; ``` -------------------------------- ### Path Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Configuration for the target path(s). ```APIDOC ## Path Option ### Description Configuration for the target path(s). ### Type `boolean | Type | Type[] | Set` ### Default `"./Target"` ``` -------------------------------- ### Add Multiple Compression Paths Source: https://github.com/playform/compress/blob/Current/README.md Specify an array of paths to compress, allowing for multiple output directories to be processed. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Path: ["./Target", "./Build"], }), ], }; ``` -------------------------------- ### Interface Constructor Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Integration.Interface.html The Interface constructor allows for optional configuration to integrate with Astro. It returns an array of AstroIntegration. ```APIDOC ## Interface Constructor ### Description Initializes the Interface with optional settings and returns AstroIntegration configurations. ### Method Interface ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "example": "Interface({ theme: 'dark' })" } ``` ### Response #### Success Response (AstroIntegration) - **AstroIntegration** (Array) - An array of AstroIntegration objects. #### Response Example ```json { "example": "[AstroIntegrationObject1, AstroIntegrationObject2]" } ``` ``` -------------------------------- ### Map Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Configures mapping to different file paths. ```APIDOC ## Map Option ### Description Configures mapping to different file paths. ### Type `boolean | Interface` (referencing `Map.Interface.html`) ``` -------------------------------- ### Apply Compress Integration in Astro Config Source: https://github.com/playform/compress/blob/Current/README.md Apply the Compress integration to your Astro project by importing and including it in the `integrations` array in your `astro.config.ts` file. ```typescript export default { integrations: [(await import("@playform/compress")).default()], }; ``` -------------------------------- ### Interface Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Image_Writesharp.Interface.html Represents the Interface for image writing operations. It takes an Option and an On interface as parameters and returns a Promise. ```APIDOC ## Interface ### Description This is the main interface for image writing operations. It accepts an 'Option' and an 'On' interface, returning a Promise that resolves with any. ### Parameters * **Option** (`Interface` from `Interface_Image_sharp.Interface`): Configuration options for the image writing process. * **On** (`Interface` from `Interface_Image_Onsharp.Interface`): Specifies the 'on' behavior or callbacks for the image writing process. ### Returns * `Promise`: A Promise that resolves with the result of the image writing operation. ``` -------------------------------- ### Array of Paths and Maps for Compression Source: https://github.com/playform/compress/blob/Current/README.md Combine an array of paths with a Map for complex input-output directory configurations. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Path: [ // Compress Target "./Target", // Compress Target one more time into a different directory new Map([["./Target", "./TargetCompress"]]), ], }), ], }; ``` -------------------------------- ### File Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html File patterns to be matched. ```APIDOC ## File Option ### Description File patterns to be matched. ### Type `string | boolean | string[]` ``` -------------------------------- ### Usage Option for CompressOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Provides usage data for advanced CSS optimization techniques. ```typescript usage?: Usage ``` -------------------------------- ### Default Compression Configuration Source: https://github.com/playform/compress/blob/Current/README.md Configure default compression options for various file types. Set specific compression libraries or disable compression for certain types. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ CSS: false, HTML: { "html-minifier-terser": { removeAttributeQuotes: false, }, }, Image: false, JavaScript: false, JSON: false, SVG: false, }), ], }; ``` -------------------------------- ### Before Compress Option for MinifyOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html A hook that is called immediately after the CSS parsing phase. ```typescript beforeCompress?: BeforeCompressFn | BeforeCompressFn[] ``` -------------------------------- ### pseudoClasses Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_lightningcss.Interface.html Replaces user action pseudo classes with class names that can be applied from JavaScript, useful for polyfills. ```APIDOC ## pseudoClasses ### Description Replaces user action pseudo classes with class names that can be applied from JavaScript. This is useful for polyfills, for example. ### Type `PseudoClasses` ### Optional This property is optional. ``` -------------------------------- ### analyzeDependencies Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_lightningcss.Interface.html Enables analysis of dependencies like `@import` and `url()`. When enabled, `@import` rules are removed, and `url()` dependencies are replaced with hashed placeholders. Dependencies are returned as part of the result. ```APIDOC ## analyzeDependencies ### Description Whether to analyze dependencies (e.g. `@import` and `url()`). When enabled, `@import` rules are removed, and `url()` dependencies are replaced with hashed placeholders that can be replaced with the final urls later (after bundling). Dependencies are returned as part of the result. ### Type `boolean | DependencyOptions` ### Optional This property is optional. ``` -------------------------------- ### Source Map Option for MinifyOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Generates a source map when set to true, aiding in debugging compressed CSS. ```typescript sourceMap?: boolean ``` -------------------------------- ### cssModules Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_lightningcss.Interface.html Determines if the file should be compiled as a CSS module. Accepts a boolean or a CSSModulesConfig object. ```APIDOC ## cssModules ### Description Whether to compile this file as a CSS module. ### Type `boolean | CSSModulesConfig` ### Optional This property is optional. ``` -------------------------------- ### Interface Image Onsharp Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Image_Onsharp.Interface.html The Interface Image Onsharp defines the structure for image processing operations, including buffer, input/output file paths, and size before/after processing. ```APIDOC ## Interface Interface ### Description Defines the structure for image processing operations. ### Properties * **Buffer** (object & Sharp) - Required - A buffer containing image data, potentially with additional key-value pairs. * **Input** (string) - Required - The path to the input image file. * **Output** (string) - Required - The path for the output processed image file. * **After** (number) - Required - The size of the image file after processing. * **Before** (number) - Required - The size of the image file before processing. ``` -------------------------------- ### Cache Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Configuration for the target cache. ```APIDOC ## Cache Option ### Description Configuration for the target cache. ### Type `boolean | Interface` ### Default `{ Search: "./", Folder: "./Cache" }` ``` -------------------------------- ### Interface Parser Configuration Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html The Interface Parser defines optional configuration settings for different types of assets that can be compressed. It allows specifying compression methods for CSS, HTML, Images, JavaScript, and SVG. It also supports arbitrary string keys for custom configurations. ```APIDOC ## Interface Interface This interface defines the structure for configuring compression settings. ### Properties * **CSS?** (Type | Type[]) - Optional. Specifies CSS compression options. Can be a single type or an array of types. * **HTML?** ("html-minifier-terser" | "html-minifier-terser"[]) - Optional. Specifies HTML compression options. Accepts 'html-minifier-terser' or an array of it. * **Image?** ("sharp" | "sharp"[]) - Optional. Specifies image compression options. Accepts 'sharp' or an array of it. * **JavaScript?** ("terser" | "terser"[]) - Optional. Specifies JavaScript compression options. Accepts 'terser' or an array of it. * **SVG?** ("svgo" | "svgo"[]) - Optional. Specifies SVG compression options. Accepts 'svgo' or an array of it. * **[key: string]** (any) - Optional. Allows for arbitrary string keys to specify custom configurations. ``` -------------------------------- ### Interface Configuration Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_lightningcss.Interface.html The Interface defines various optional properties to configure the CSS processing behavior, including minification, source maps, targets, and more. ```APIDOC ## Interface ### Description Defines configuration options for CSS processing. ### Properties * **minify** (boolean) - Optional - Whether to enable minification. Defaults to `true` for Compress and `false` for lightningcss. * **unusedSymbols** (string[]) - Optional - Whether to remove unused selectors or keywords. Defaults to `[]` for Compress and `undefined` for lightningcss. * **sourceMap** (boolean) - Optional - Whether to output a source map. * **inputSourceMap** (string) - Optional - An input source map to extend. * **projectRoot** (string) - Optional - An optional project root path, used as the source root in the output source map. * **targets** (Targets) - Optional - The browser targets for the generated code. * **include** (number) - Optional - Features that should always be compiled, even when supported by targets. * **exclude** (number) - Optional - Features that should never be compiled, even when unsupported by targets. * **drafts** (Drafts) - Optional - Whether to enable parsing various draft syntax. * **nonStandard** (NonStandard) - Optional - Configuration for non-standard CSS features. * **cssModules** (boolean | CSSModulesConfig) - Optional - Configuration for CSS Modules. * **analyzeDependencies** (boolean | DependencyOptions) - Optional - Configuration for analyzing dependencies. * **pseudoClasses** (PseudoClasses) - Optional - Configuration for pseudo-classes. * **errorRecovery** (boolean) - Optional - Whether to enable error recovery. * **visitor** (Visitor) - Optional - A visitor function for custom at-rules. * **customAtRules** (CustomAtRules) - Optional - Configuration for custom at-rules. ``` -------------------------------- ### Interface Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html Defines the configuration interface for compression options, including specific settings for CSS, HTML, Image, JavaScript, and SVG, as well as general indexable properties. ```typescript interface Interface { [CSS](#css)?: Type | Type[]; [HTML](#html)?: "html-minifier-terser" | "html-minifier-terser"[]; [Image](#image)?: "sharp" | "sharp"[]; [JavaScript](#javascript)?: "terser" | "terser"[]; [SVG](#svg)?: "svgo" | "svgo"[]; [key: string]: any; } ``` -------------------------------- ### Compress Specific Output Directory Source: https://github.com/playform/compress/blob/Current/README.md Configure the 'Path' option to specify a custom output directory for compression, overriding the default 'outDir'. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Path: ["./dist", "./Compress"], }), ], }; ``` -------------------------------- ### Filename Option for MinifyOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Specifies the filename of the input CSS, used for generating source maps. Defaults to ''. ```typescript filename?: string ``` -------------------------------- ### Interface Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html The Interface Option defines the configuration structure for the @playform/compress library. It allows users to enable or disable compression for different file types and specify detailed options for each. ```APIDOC ## Interface Option ### Description Defines the configuration options for various compression modules. ### Properties - **CSS?** (boolean | Partial<{ csso?: boolean | Interface; lightningcss?: boolean | Interface }>) - Description: csso, lightningcss option properties. - **HTML?** (boolean | Partial<{ "html-minifier-terser"?: boolean | Options }>) - Description: html-minifier-terser option properties. - **Image?** (boolean | Partial<{ sharp?: boolean | Interface }>) - Description: sharp option properties. - **JavaScript?** (boolean | Partial<{ terser?: boolean | MinifyOptions }>) - Description: terser option properties. - **SVG?** (boolean | Partial<{ svgo?: boolean | Config }>) - Description: svgo option properties. - **JSON?** (boolean | Partial<{ replacer?: (string | number)[] | null; space?: string | number }>) - Description: JSON replacer and space options. - **Map?** (boolean | Interface) - Description: Map options. - **Parser?** (Interface) - Description: Parser options. - **Cache?** (boolean | Interface) - Description: Cache options. - **Path?** (boolean | Type | Type[] | Set) - Description: Path configuration. - **Exclude?** (boolean | Type | Type[] | Set) - Description: Exclude configuration. - **File?** (string | boolean | string[]) - Description: File configuration. - **Action?** (boolean | Interface) - Description: Action options. - **Logger?** (boolean | Type) - Description: Logger options. ``` -------------------------------- ### After Compress Option for MinifyOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html A hook that is called after the CSS compression process is completed. ```typescript afterCompress?: AfterCompressFn | AfterCompressFn[] ``` -------------------------------- ### Clone Option for CompressOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html When true, transforms a copy of the input AST, which is useful if the original AST needs to be reused. ```typescript clone?: boolean ``` -------------------------------- ### customAtRules Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_lightningcss.Interface.html Defines how to parse custom CSS at-rules, specifying their prelude and body format. ```APIDOC ## customAtRules ### Description Defines how to parse custom CSS at-rules. Each at-rule can have a prelude, defined using a CSS [syntax string](https://drafts.css-houdini.org/css-properties-values-api/#syntax-strings), and a block body. The body can be a declaration list, rule list, or style block as defined in the [css spec](https://drafts.csswg.org/css-syntax/#declaration-rule-list). ### Type `CustomAtRules` ### Optional This property is optional. ``` -------------------------------- ### nonStandard Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_lightningcss.Interface.html Controls whether to enable various non-standard syntax features. This option is inherited. ```APIDOC ## nonStandard ### Description Whether to enable various non-standard syntax. ### Type `NonStandard` ### Optional This property is optional. ``` -------------------------------- ### Logger Option for CompressOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html A function that can be provided to track each step of the CSS transformation process. ```typescript logger?: () => void ``` -------------------------------- ### Image Property Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html Defines the optional Image compression configuration, allowing 'sharp' as the value, either as a single string or an array. ```typescript Image?: "sharp" | "sharp"[] ``` -------------------------------- ### HTML Minifier Terser Configuration Object Source: https://github.com/playform/compress/blob/Current/docs/variables/Variable_HTML_html-minifier-terser.htmlMinifierTerser.html This object defines the configuration settings for the HTML minifier. Each property controls a specific aspect of the minification process. Adjust these settings to fine-tune the HTML output. ```typescript htmlMinifierTerser: { caseSensitive: true; collapseInlineTagWhitespace: false; collapseWhitespace: true; continueOnParseError: true; html5: true; ignoreCustomComments: RegExp[]; ignoreCustomFragments: never[]; includeAutoGeneratedTags: true; keepClosingSlash: true; minifyCSS: true; minifyJS: true; minifyURLs: false; noNewlinesBeforeTagClose: true; preventAttributesEscaping: false; processConditionalComments: false; processScripts: string[]; quoteCharacter: string; removeAttributeQuotes: true; removeComments: true; removeScriptTypeAttributes: true; removeStyleLinkTypeAttributes: true; removeTagWhitespace: false; sortAttributes: true; sortClassName: true; trimCustomFragments: true; useShortDoctype: false; } ``` -------------------------------- ### Interface Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Directory.Interface.html The Interface function takes a string representing a path and returns a Promise that resolves to a string. This is likely used for directory operations within the PlayForm system. ```APIDOC ## Interface ### Description Initializes or interacts with a directory interface, returning a promise that resolves to a string. ### Method Interface ### Parameters #### Path Parameters - **Path** (string) - Required - The path to the directory. ### Returns [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)` ### Optional This property is optional. ``` -------------------------------- ### JSON Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Configures JSON processing, including optional replacer and space settings. ```APIDOC ## JSON Option ### Description Configures JSON processing, including optional replacer and space settings. ### Type `boolean | Partial<{ replacer?: (string | number)[] | null; space?: string | number }>` ``` -------------------------------- ### Parser Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Specifies parsers for different file types. ```APIDOC ## Parser Option ### Description Specifies parsers for different file types. ### Type `Interface` (referencing `Interface_Parser.Interface.html`) ``` -------------------------------- ### Image Sharp Interface Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Image_sharp.Interface.html Defines the structure for image processing options, including support for various formats and custom string keys. ```typescript interface Interface { [avif](#avif)?: boolean | AvifOptions; [gif](#gif)?: boolean | GifOptions; [heif](#heif)?: boolean | HeifOptions; [jpeg](#jpeg)?: boolean | JpegOptions; [png](#png)?: boolean | PngOptions; [tiff](#tiff)?: boolean | TiffOptions; [webp](#webp)?: boolean | WebpOptions; [sharp](#sharp)?: boolean | SharpOptions; [key: string]: | boolean | AvifOptions | GifOptions | HeifOptions | JpegOptions | PngOptions | SharpOptions | TiffOptions | WebpOptions | undefined; } ``` -------------------------------- ### Logger Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Debugging level. ```APIDOC ## Logger Option ### Description Debugging level. ### Type `boolean | Type` ### Default `2` ``` -------------------------------- ### Debug Option for MinifyOptions Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Enables the output of debug information to stderr. Defaults to false. ```typescript debug?: boolean ``` -------------------------------- ### Interface CSS csso Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Defines the configuration options for the CSS csso interface, allowing fine-grained control over the compression process. ```APIDOC ## Interface CSS csso ### Description This interface defines the configuration options for the CSS csso compression process. It allows users to customize various aspects of how CSS is minified and optimized. ### Properties #### `Optional` comments (boolean) Specify what comments to leave: * 'exclamation' or true – leave all exclamation comments * 'first-exclamation' – remove every comment except first one * false – remove all comments **Default:** * Compress: `false` * csso: `true` Overrides `CompressOptions.comments`. #### `Optional` forceMediaMerge (boolean) Enables merging of rules with the same media query by splitted by other rules. The optimisation is unsafe in general, but should work fine in most cases. Use it on your own risk. **Default:** * Compress: `true` * csso: `false` Overrides `CompressOptions.forceMediaMerge`. #### `Optional` restructure (boolean) Disable or enable a structure optimisations. **Default:** * CompressAstro: `false` * csso: `true` Overrides `MinifyOptions.restructure`. #### `Optional` clone (boolean) Transform a copy of input AST if true. Useful in case of AST reuse. **Default:** `false` Inherited from `CompressOptions.clone`. #### `Optional` usage (Usage) Usage data for advanced optimisations. Inherited from `CompressOptions.usage`. #### `Optional` logger (() => void) Function to track every step of transformation. Inherited from `CompressOptions.logger`. #### `Optional` sourceMap (boolean) Generate a source map when true. **Default:** `false` Inherited from `MinifyOptions.sourceMap`. #### `Optional` filename (string) Filename of input CSS, uses for source map generation. **Default:** `''` Inherited from `MinifyOptions.filename`. #### `Optional` debug (boolean) Output debug information to stderr. **Default:** `false` Inherited from `MinifyOptions.debug`. #### `Optional` beforeCompress (BeforeCompressFn | BeforeCompressFn[]) Called right after parse is run. Inherited from `MinifyOptions.beforeCompress`. #### `Optional` afterCompress (AfterCompressFn | AfterCompressFn[]) Called right after compression is run. Inherited from `MinifyOptions.afterCompress`. ``` -------------------------------- ### Variable Option Structure Source: https://github.com/playform/compress/blob/Current/docs/variables/Variable_Option.option.html Defines the structure of the configuration 'option' object for @playform/compress. This object specifies settings for file paths, caching, logging, actions, and optimization parameters for different file types. ```typescript option: { Path: string; Cache: { Search: string; Folder: string }; Logger: 2; Action: { Failed: (__namedParameters: Interface) => Promise; Passed: (__namedParameters: Interface) => Promise; Accomplished: (__namedParameters: Interface) => Promise; Changed: (Plan: Interface) => Promise; Read: (__namedParameters: Interface) => Promise; Wrote: (__namedParameters: Interface) => Promise; Fulfilled: (__namedParameters: Interface) => Promise; }; File: string; Exclude: false; CSS: { csso: Interface; lightningcss: false }; HTML: { "html-minifier-terser": { caseSensitive: true; collapseInlineTagWhitespace: false; collapseWhitespace: true; continueOnParseError: true; html5: true; ignoreCustomComments: RegExp[]; ignoreCustomFragments: never[]; includeAutoGeneratedTags: true; keepClosingSlash: true; minifyCSS: true; minifyJS: true; minifyURLs: false; noNewlinesBeforeTagClose: true; preventAttributesEscaping: false; processConditionalComments: false; processScripts: string[]; quoteCharacter: string; removeAttributeQuotes: true; removeComments: true; removeScriptTypeAttributes: true; removeStyleLinkTypeAttributes: true; removeTagWhitespace: false; sortAttributes: true; sortClassName: true; trimCustomFragments: true; useShortDoctype: false; }; }; Image: { sharp: Interface }; JavaScript: { terser: { ecma: 5; enclose: false; keep_classnames: false; keep_fnames: false; ie8: false; module: false; safari10: false; toplevel: false; format: { comments: false }; }; }; SVG: { svgo: { multipass: true; js2svg: { indent: number; pretty: false }; plugins: "preset-default"[] } }; JSON: true; Map: Interface; Parser: Interface; } ``` -------------------------------- ### File Exclusion for Compression Source: https://github.com/playform/compress/blob/Current/README.md Exclude specific files or use functions to match file names for exclusion from compression. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Exclude: [ "File.png", (File: string) => File === "./Target/Favicon/Image/safari-pinned-tab.svg", ], }), ], }; ``` -------------------------------- ### errorRecovery Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_lightningcss.Interface.html Configures whether to ignore invalid rules and declarations instead of erroring. When enabled, warnings are returned, and invalid parts are omitted from the output. ```APIDOC ## errorRecovery ### Description Whether to ignore invalid rules and declarations rather than erroring. When enabled, warnings are returned, and the invalid rule or declaration is omitted from the output code. ### Type `boolean` ### Optional This property is optional. ``` -------------------------------- ### Disable All Compression Source: https://github.com/playform/compress/blob/Current/README.md Completely disable all compression features by setting each file type to false. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ CSS: false, HTML: false, Image: false, JavaScript: false, JSON: false, SVG: false, }), ], }; ``` -------------------------------- ### Force Media Merge Option for csso Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Enables merging of CSS rules with identical media queries, even if separated by other rules. Use with caution as it's generally unsafe but often works. ```typescript forceMediaMerge?: boolean ``` -------------------------------- ### HTML Property Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html Defines the optional HTML compression configuration, specifying 'html-minifier-terser' as the allowed value, either as a single string or an array. ```typescript HTML?: "html-minifier-terser" | "html-minifier-terser"[] ``` -------------------------------- ### Terser Configuration Object Source: https://github.com/playform/compress/blob/Current/docs/variables/Variable_JavaScript_terser.terser.html Defines the configuration object for Terser, a JavaScript minifier. This object specifies various options to control the minification process. ```javascript terser: { ecma: 5, enclose: false, keep_classnames: false, keep_fnames: false, ie8: false, module: false, safari10: false, toplevel: false, format: { comments: false } } ``` -------------------------------- ### CSS Property Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html Defines the optional CSS compression configuration, which can be a single Type or an array of Types. ```typescript CSS?: Type | Type[] ``` -------------------------------- ### Filter Files for Compression Exclusion Source: https://github.com/playform/compress/blob/Current/docs/index.html Exclude specific files or patterns from compression using the `Exclude` option. This can be an array of strings (filenames) or functions that return true for files to be excluded. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Exclude: [ "File.png", (File: string) => File === "./Target/Favicon/Image/safari-pinned-tab.svg", ], }), ], }; ``` -------------------------------- ### Exclude Option Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Option.Interface.html Criteria for excluding files. ```APIDOC ## Exclude Option ### Description Criteria for excluding files. ### Type `boolean | Type | Type[] | Set` ``` -------------------------------- ### SVG Property Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html Defines the optional SVG compression configuration, allowing 'svgo' as the value, either as a single string or an array. ```typescript SVG?: "svgo" | "svgo"[] ``` -------------------------------- ### CSS csso Interface Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Defines the configuration interface for the csso CSS compressor. Use these properties to customize compression behavior. ```typescript interface Interface { [comments](#comments)?: boolean; [forceMediaMerge](#forcemediamerge)?: boolean; [restructure](#restructure)?: boolean; [clone](#clone)?: boolean; [usage](#usage)?: Usage; [logger](#logger)?: () => void; [sourceMap](#sourcemap)?: boolean; [filename](#filename)?: string; [debug](#debug)?: boolean; [beforeCompress](#beforecompress)?: BeforeCompressFn | BeforeCompressFn[]; [afterCompress](#aftercompress)?: AfterCompressFn | AfterCompressFn[]; } ``` -------------------------------- ### Manual Override for Dependency Conflict Source: https://github.com/playform/compress/blob/Current/Documentation/GitHub/Why-Astro-Is-Not-In-peerDependencies.md This JSON snippet shows how to manually override a specific transitive dependency version in package.json to resolve conflicts. Use this when a direct dependency pulls in an incompatible version of a shared package. ```json { "overrides": { "@astrojs/internal-helpers": "0.8.0" } } ``` -------------------------------- ### JavaScript Property Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html Defines the optional JavaScript compression configuration, specifying 'terser' as the allowed value, either as a single string or an array. ```typescript JavaScript?: "terser" | "terser"[] ``` -------------------------------- ### Indexable Property Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Parser.Interface.html Shows the definition for an indexable property within the Interface, allowing for arbitrary string keys with any value. This is often used for custom configurations. ```typescript [key: string]: any; // biome-ignore lint/suspicious/noExplicitAny: ``` -------------------------------- ### Restructure Option for csso Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Disables or enables structural optimizations in the CSS compressor. Defaults to true for csso. ```typescript restructure?: boolean ``` -------------------------------- ### Control Logging Level Source: https://github.com/playform/compress/blob/Current/README.md Set the 'Logger' parameter to control the verbosity of compression logs. A value of 0 disables debug messages. ```typescript export default { integrations: [ (await import("@playform/compress")).default({ Logger: 0, }), ], }; ``` -------------------------------- ### Merge Function Implementation Signature Source: https://github.com/playform/compress/blob/Current/docs/variables/Function_Integration.Merge.html This shows the signature of the Merge function implementation. It accepts a variable number of objects and returns a DeepMergeHKT type, specifying merge strategies and parent tracking. ```typescript Merge(...objects: Ts): DeepMergeHKT, Readonly<{ key: PropertyKey; parents: readonly Readonly>[] }>)> ``` -------------------------------- ### Indexable Property Definition Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_Image_sharp.Interface.html Specifies that the interface can be indexed by any string key, accepting various image format options or a boolean. ```typescript [key: string]: | boolean | AvifOptions | GifOptions | HeifOptions | JpegOptions | PngOptions | SharpOptions | TiffOptions | WebpOptions | undefined ``` -------------------------------- ### Comments Option for csso Source: https://github.com/playform/compress/blob/Current/docs/interfaces/Interface_CSS_csso.Interface.html Controls which comments are preserved during CSS compression with csso. Set to 'exclamation' or true to keep all exclamation comments, 'first-exclamation' for only the first, or false to remove all. ```typescript comments?: boolean ``` -------------------------------- ### Parser Type Alias Definition Source: https://github.com/playform/compress/blob/Current/docs/types/Parser.Type-2.html Defines the 'Type' alias for image parsing, specifying 'sharp' as a possible value. This is used internally by the library. ```typescript type Type = "sharp"; ``` -------------------------------- ### merge Source: https://github.com/playform/compress/blob/Current/docs/variables/Merge.merge.html Deeply merges multiple objects into a single object. It allows for custom merge strategies for records, arrays, sets, maps, and other types, providing fine-grained control over the merging process. ```APIDOC ## merge ### Description Deeply merges multiple objects into a single object. It allows for custom merge strategies for records, arrays, sets, maps, and other types, providing fine-grained control over the merging process. ### Type Declaration ```typescript (...objects: Ts) => DeepMergeHKT, Readonly<{ key: PropertyKey; parents: readonly Readonly>[] }>) ``` ### Type Parameters * **Ts** extends `readonly unknown[]` The tuple of objects to merge. ### Parameters * **...objects**: `Ts` A variable number of objects to be merged. ### Returns A `DeepMergeHKT` instance representing the deeply merged result, incorporating custom merge strategies and parent tracking. ### Source * Defined in [Application/PlayForm/NPM/Compress/Source/Function/Merge.ts:5](https://github.com/PlayForm/Compress/blob/Current/Source/Function/Merge.ts#L5) ``` -------------------------------- ### Merge Function Type Declaration Source: https://github.com/playform/compress/blob/Current/docs/variables/Merge.merge.html This is the type declaration for the merge function. It uses variadic arguments and a HKT (Higher-Kinded Type) to define a flexible deep merge operation. It allows customization of merge strategies for different data types. ```typescript merge: ( ...objects: Ts, ) => DeepMergeHKT< Ts, Readonly<{ DeepMergeRecordsURI: "DeepMergeRecordsDefaultURI"; DeepMergeArraysURI: "DeepMergeArraysDefaultURI"; DeepMergeSetsURI: "DeepMergeSetsDefaultURI"; DeepMergeMapsURI: "DeepMergeMapsDefaultURI"; DeepMergeOthersURI: "DeepMergeLeafURI"; DeepMergeFilterValuesURI: "DeepMergeFilterValuesDefaultURI"; }>, Readonly<{ key: PropertyKey; parents: readonly Readonly>[] }> > ``` -------------------------------- ### Parser Type Alias Definition Source: https://github.com/playform/compress/blob/Current/docs/types/Parser.Type-1.html Defines the Type alias for the parser, specifying 'html-minifier-terser' as the concrete type. This is used internally by the library. ```typescript type Type = "html-minifier-terser"; ``` -------------------------------- ### Merge Function Type Declaration Source: https://github.com/playform/compress/blob/Current/docs/variables/Function_Integration.Merge.html This is the type declaration for the Merge function. It uses a generic type 'Ts' to accept a variadic number of objects for deep merging. It defines default URIs for various merge strategies and includes a type for parent tracking. ```typescript Merge(...objects: Ts) => DeepMergeHKT, Readonly<{ key: PropertyKey; parents: readonly Readonly>[] }>)> ``` -------------------------------- ### Parser Type Alias Definition Source: https://github.com/playform/compress/blob/Current/docs/types/Parser.Type-3.html Defines the 'Type' type alias for the JavaScript parser. This alias is restricted to the string literal 'terser'. ```typescript type Type = "terser"; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.