compactor

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &Bundle{
	Destination: Destination{
		Hashed: true,
	},
	Compress: Compress{
		Enabled: true,
	},
	SourceMap: SourceMap{
		Enabled: true,
	},
	Progressive: Progressive{
		Enabled: true,
	},
}

Default bundle model

Functions

func AddPlugin added in v0.0.12

func AddPlugin(plugin *Plugin)

AddPlugin add a new plugin to the index

func Append added in v0.0.4

func Append(path string, root string) error

Append file path information to index

func Index added in v0.0.4

func Index(path string) error

Index add path files to the index, resolve related and create bundles

func IndexBundles added in v0.0.12

func IndexBundles() error

IndexBundles creates and retrieve every possible bundle with current index

func IndexItems added in v0.0.12

func IndexItems(root string) error

IndexItems walks on path and add files to the index

func IndexRelated added in v0.0.12

func IndexRelated() error

IndexRelated detect the related assets on the index

func Process

func Process(bundle *Bundle) error

Process execute bundle packaging by running plugin

func Remove added in v0.0.2

func Remove(path string)

Remove item information from index if match file path

func RemovePlugin added in v0.0.12

func RemovePlugin(namespace string)

RemovePlugin removes all plugins from index that match the given namespace

func SetBundles added in v0.0.12

func SetBundles(bundles []*Bundle)

SetBundles renew the index of bundles with a new list

func Update added in v0.0.4

func Update(path string) error

Update item information on index if match file path

Types

type Bundle added in v0.0.2

type Bundle struct {
	Extension   string
	Item        *Item
	Source      Source
	Destination Destination
	Compress    Compress
	SourceMap   SourceMap
	Progressive Progressive
}

Bundle struct

func GetBundle added in v0.0.12

func GetBundle(path string) *Bundle

GetBundle retrieve the related bundle for the file

func GetBundles added in v0.0.4

func GetBundles() []*Bundle

GetBundles retrieve all bundles in the index

func (*Bundle) CleanPath added in v0.0.3

func (b *Bundle) CleanPath(file string) string

CleanPath return the clean file, without source and destination path

func (*Bundle) MatchPatterns added in v0.0.3

func (b *Bundle) MatchPatterns(file string, patterns []string) bool

MatchPatterns return if file match one of the given patterns

func (*Bundle) ShouldCompress added in v0.0.3

func (b *Bundle) ShouldCompress(file string) bool

ShouldCompress return if compress should be enabled for given file

func (*Bundle) ShouldGenerateProgressive added in v0.0.3

func (b *Bundle) ShouldGenerateProgressive(file string) bool

ShouldGenerateProgressive return if progressive formats should be generated for given file

func (*Bundle) ShouldGenerateSourceMap added in v0.0.3

func (b *Bundle) ShouldGenerateSourceMap(file string) bool

ShouldGenerateSourceMap return if source map should be generated for given file

func (*Bundle) ShouldInclude added in v0.0.4

func (b *Bundle) ShouldInclude(file string) bool

ShouldInclude return if file should be included on the bundle

func (*Bundle) ToDestination added in v0.0.3

func (b *Bundle) ToDestination(file string) string

ToDestination transform and return the full destination path for file

func (*Bundle) ToExtension added in v0.0.3

func (b *Bundle) ToExtension(file string, extension string) string

ToExtension return a file converted to a specific extension

func (*Bundle) ToHashed added in v0.0.3

func (b *Bundle) ToHashed(file string, hash string) string

ToHashed return a file converted to a hashed name to avoid caching

func (*Bundle) ToNonHashed added in v0.0.11

func (b *Bundle) ToNonHashed(file string, hash string) string

ToNonHashed return a file converted back to a non hashed name

func (*Bundle) ToSource added in v0.0.3

func (b *Bundle) ToSource(file string) string

ToSource transform and return the full source path for file

type Compress added in v0.0.2

type Compress struct {
	Enabled bool
	Include []string
	Exclude []string
}

Compress struct

type DeleteFunc added in v0.0.4

type DeleteFunc = func(bundle *Bundle) error

Delete function

type Destination added in v0.0.3

type Destination struct {
	Path   string
	Hashed bool
}

Destination struct

type ExecuteFunc added in v0.0.12

type ExecuteFunc = func(bundle *Bundle) error

Execute function

type InitFunc added in v0.0.6

type InitFunc = func(bundle *Bundle) error

Init function

type Item added in v0.0.4

type Item struct {
	Path       string      // Full path (root + location)
	Root       string      // Root location
	Location   string      // Location from root
	Folder     string      // Location folder
	File       string      // File name with extension
	Name       string      // File name
	Extension  string      // File Extension
	Content    string      // File content
	Permission fs.FileMode // File permissions
	Exists     bool        // File exists flag
	Checksum   string      // Current Checksum
	Previous   string      // Previous Checksum
	Related    []Related   // Related items
}

Item struct

func Get added in v0.0.4

func Get(path string) *Item

Get the item that match file path on index

func Matches added in v0.0.4

func Matches(callback func(item *Item) bool) []*Item

Matches run callback on index and append item if match

func (*Item) GetRelatedPaths added in v0.0.17

func (i *Item) GetRelatedPaths(onlyDependencies bool) []string

GetRelatedPaths retrieve the related paths of the item

type OptimizeFunc added in v0.0.12

type OptimizeFunc = func(bundle *Bundle) error

Optimize function

type Plugin added in v0.0.4

type Plugin struct {
	Namespace  string
	Extensions []string
	Init       InitFunc
	Related    RelatedFunc
	Resolve    ResolveFunc
	Execute    ExecuteFunc
	Optimize   OptimizeFunc
	Delete     DeleteFunc
}

Plugin struct

func GetPlugin added in v0.0.12

func GetPlugin(extension string) *Plugin

GetPlugin retrieves the first found plugin for the given extension

type Progressive added in v0.0.2

type Progressive struct {
	Enabled bool
	Include []string
	Exclude []string
}

Progressive struct

type Related struct {
	Type       string
	Dependency bool
	Source     string
	Path       string
	Item       *Item
}

Related struct

type RelatedFunc added in v0.0.12

type RelatedFunc = func(item *Item) ([]Related, error)

Related function

type ResolveFunc added in v0.0.4

type ResolveFunc = func(file string, item *Item) (string, error)

Resolve function

type Source added in v0.0.3

type Source struct {
	Path    string
	Include []string
	Exclude []string
}

Source struct

type SourceMap added in v0.0.2

type SourceMap struct {
	Enabled bool
	Include []string
	Exclude []string
}

SourceMap struct

Jump to

Keyboard shortcuts

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