Skip to content

Package combine provides interface to create assets with multiple source of contents (bytes, string, file path or URL)

License

Notifications You must be signed in to change notification settings

rvflash/combine

Repository files navigation

Combine

GoDoc Build Status Code Coverage Go Report Card

Package combine provides interface to create assets with multiple source of contents (bytes, string, file path or URL). It combines and minifies them on the fly on the first demand on the dedicated file server.

Installation

$ go get github.com/rvflash/combine
$ cd $GOPATH/src/github.com/rvflash/combine
$ dep ensure

Usage

See example for real usage. Errors are ignored for the demo.

import "github.com/rvflash/combine"
// ...
// Creates a box with the path to the local file resources
// and the path to store combined / minified assets.
static := combine.NewBox("./src", "./combine")
// Deletes all files cache on exit. 
defer func() { _ = static.Close() }()
// ...
// Creates a asset.
css := static.NewCSS()
_ = css.AddURL("https://raw.githubusercontent.com/twbs/bootstrap/v4-dev/dist/css/bootstrap-reboot.css")
_ = css.AddString(".blue{ color: #4286f4; }")
_ = css.AddFile("local/file/is_src_dir.css")
// Uses it in a HTML template by retrieving its path or tag.
// By default, a build version will also added.
tag := css.Tag("/static/")
// ...
// Serves combined and minifed resousrces
http.Handle("/static/", http.FileServer(static))
http.ListenAndServe(":8080", nil)

About

Package combine provides interface to create assets with multiple source of contents (bytes, string, file path or URL)

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages