minifiers

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package minifiers contains minifiers mapped to MIME types. This package is used in both the resource transformation, i.e. resources.Minify, and in the publishing chain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Whether output minification is enabled (HTML in /public)
	MinifyOutput bool
	// contains filtered or unexported fields
}

Client wraps a minifier.

func New

func New(mediaTypes media.Types, outputFormats output.Formats, cfg config.AllProvider) (Client, error)

New creates a new Client with the provided MIME types as the mapping foundation. The HTML minifier is also registered for additional HTML types (AMP etc.) in the provided list of output formats.

func (Client) Minify

func (m Client) Minify(mediatype media.Type, dst io.Writer, src io.Reader) error

Minify tries to minify the src into dst given a MIME type.

func (Client) Transformer

func (m Client) Transformer(mediatype media.Type) transform.Transformer

Transformer returns a func that can be used in the transformer publishing chain. TODO(bep) minify config etc

type MinifyConfig

type MinifyConfig struct {
	// Whether to minify the published output (the HTML written to /public).
	MinifyOutput bool

	DisableHTML bool
	DisableCSS  bool
	DisableJS   bool
	DisableJSON bool
	DisableSVG  bool
	DisableXML  bool

	Tdewolff TdewolffConfig
}

func DecodeConfig

func DecodeConfig(v any) (conf MinifyConfig, err error)

type TdewolffConfig

type TdewolffConfig struct {
	HTML html.Minifier
	CSS  css.Minifier
	JS   js.Minifier
	JSON json.Minifier
	SVG  svg.Minifier
	XML  xml.Minifier
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL