compactor

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 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 Append added in v0.0.4

func Append(path string) error

Append file path information to indexer

func Index added in v0.0.4

func Index(path string) error

Index walks on path and add files to the indexer

func Map added in v0.0.4

func Map(files []string, dependencies []string, destination string)

Map add a new map registration

func Process

func Process(bundle *Bundle) error

Process package by running processors

func Register added in v0.0.4

func Register(plugin *Plugin)

Register add a new plugin to the index

func Remove added in v0.0.2

func Remove(path string)

Remove item information from indexer if match file path

func Unregister added in v0.0.4

func Unregister(extension string)

Unregister removes all plugins that match the given extension

func Update added in v0.0.4

func Update(path string) error

Update item information on indexer if match file path

Types

type Bundle added in v0.0.2

type Bundle struct {
	Extension   string
	Items       []*Item
	Source      Source
	Destination Destination
	Compress    Compress
	SourceMap   SourceMap
	Progressive Progressive
	Logs        Logs
}

Bundle struct

func GetBundleFor added in v0.0.4

func GetBundleFor(path string) *Bundle

GetBundleFor retrieve the related bundle for the file

func GetBundleFromMapper added in v0.0.4

func GetBundleFromMapper(mapper *Mapper) *Bundle

GetBundleFromMapper retrieve the final bundle from given mapper

func GetBundles added in v0.0.4

func GetBundles() []*Bundle

GetBundles retrieve every possible bundle with current indexer

func NewBundle added in v0.0.3

func NewBundle() *Bundle

NewBundle create and retrieve a new bundle

func (*Bundle) CleanPath added in v0.0.3

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

Return the clean file, without source and destination path

func (*Bundle) Deleted added in v0.0.4

func (b *Bundle) Deleted(path string)

Deleted append path to deleted list

func (*Bundle) Ignored added in v0.0.4

func (b *Bundle) Ignored(path string)

Ignored append path to ignored list

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) Processed added in v0.0.4

func (b *Bundle) Processed(path string)

Processed append path to processed list

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) ShouldOutputToMany added in v0.0.4

func (b *Bundle) ShouldOutputToMany() bool

Detect if bundle should output to multiple destinations

func (*Bundle) Skipped added in v0.0.4

func (b *Bundle) Skipped(path string)

Skipped append path to skipped list

func (*Bundle) ToDestination added in v0.0.3

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

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

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

Return a file converted to a hashed name to avoid caching

func (*Bundle) ToSource added in v0.0.3

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

Transform and return the full source path for file

func (*Bundle) Written added in v0.0.4

func (b *Bundle) Written(path string)

Written append path to written list

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
	Folder string
	File   string
	Hashed bool
}

Destination struct

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
	Folder     string
	File       string
	Name       string
	Extension  string
	Content    string
	Permission fs.FileMode
	Exists     bool
	Checksum   string
	Previous   string
}

Item struct

func Get added in v0.0.4

func Get(path string) *Item

Get the item that match file path on indexer

func Matches added in v0.0.4

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

Matches run callback on indexer and append item if match

type Logs added in v0.0.4

type Logs struct {
	Processed []string
	Skipped   []string
	Ignored   []string
	Written   []string
	Deleted   []string
}

Logs struct

type Mapper added in v0.0.4

type Mapper struct {
	Files        []string
	Dependencies []string
	Destination  string
}

Mapper struct

type Plugin added in v0.0.4

type Plugin struct {
	Extensions []string
	Init       InitFunc
	Run        RunFunc
	Delete     DeleteFunc
	Resolve    ResolveFunc
}

Plugin struct

type Progressive added in v0.0.2

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

Compress struct

type ResolveFunc added in v0.0.4

type ResolveFunc = func(file string) (string, error)

Resolve function

type RunFunc added in v0.0.4

type RunFunc = func(bundle *Bundle) error

Run 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