https://github.com/rvflash/combine
Package combine provides interface to create assets with multiple source of contents (bytes, string, file path or URL)
https://github.com/rvflash/combine
assets combine golang minify
Last synced: 2 months ago
JSON representation
Package combine provides interface to create assets with multiple source of contents (bytes, string, file path or URL)
- Host: GitHub
- URL: https://github.com/rvflash/combine
- Owner: rvflash
- License: mit
- Created: 2018-02-06T22:58:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-16T12:55:32.000Z (about 7 years ago)
- Last Synced: 2025-01-28T16:16:29.048Z (4 months ago)
- Topics: assets, combine, golang, minify
- Language: Go
- Homepage:
- Size: 42 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Combine
[](https://godoc.org/github.com/rvflash/combine)
[](https://travis-ci.org/rvflash/combine)
[](http://codecov.io/github/rvflash/combine?branch=master)
[](https://goreportcard.com/report/github.com/rvflash/combine)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
```bash
$ 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.
```go
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)
```