rsbuild-plugin-compression
    Preparing search index...

    Interface CompressionPluginOptions

    interface CompressionPluginOptions {
        algorithms?: (
            "gzip"
            | "brotli"
            | "zstd"
            | CompressionAlgorithmWithOptions
        )[];
        concurrency?: number;
        disabled?: boolean | ((ctx: { environmentName: string }) => boolean);
        exclude?: AssetFilterRules;
        include?: AssetFilterRules;
        includeExtra?: IncludeExtraOptions | string[];
        printResult?: boolean;
        threshold?: number;
    }
    Index

    Properties

    algorithms?: ("gzip" | "brotli" | "zstd" | CompressionAlgorithmWithOptions)[]

    Compression algorithms to apply

    ["gzip", "brotli"]
    
    ["gzip", "brotli", "zstd"]
    
    [{name: "gzip", options: {level: 9}}, "zstd"]
    
    concurrency?: number

    How many assets will be compressed simultaneously

    4
    
    disabled?: boolean | ((ctx: { environmentName: string }) => boolean)

    Disable the plugin?

    false
    
    ({environmentName}) => environmentName !== "web"
    

    Compression won't be applied to the assets matching any of the provided conditions

    (asset) => asset.name.endsWith(".txt")
    
    [/\.(html|json)$/i]
    
    ["my-script", "my-html"]
    

    Compression will be applied only to the assets matching any of the provided conditions

    /\.(js|mjs|cjs|css|html|txt|xml|json|wasm|svg)$/i
    
    (asset) => asset.size > 16000 && asset.name.endsWith(".js")
    
    ["my-script", "my-html"]
    
    [/\.(js|mjs)$/i]
    
    includeExtra?: IncludeExtraOptions | string[]

    Glob patterns for extra assets to include that were not in the rsbuild output (for example something from the public folder or some artifacts generated by other plugins) The glob will work relative to the rsbuild output folder.

    tinyglobby is used for globbing

    ["**/*.+(js|css)"]
    
    {
    globs: ["extra/scripts/**/*"]
    }
    printResult?: boolean

    Print the compression result?

    true
    
    threshold?: number

    Minimum asset size (in bytes) to apply the compression

    0