Update dependencies to latest

Update markdown formatting to make the linter happy
This commit is contained in:
2021-09-19 13:28:05 -05:00
parent c2a01f273c
commit e4085c5754
4 changed files with 127 additions and 52 deletions

View File

@ -10,7 +10,7 @@ The only Golang-based solutions I was able to find were either purpose-built for
## How is this different?
You provide a list of files that you would like to be compiled into one file, in the order you'd like them compiled in, and the library will combine, optionally minify them using https://github.com/tdewolff/minify, and generate an output file with the sha256 signature of the file in the filename. Your application can consume the generated byte buffers and handle them as you please, or you can have the library write the files out to a specified directory.
You provide a list of files that you would like to be compiled into one file, in the order you'd like them compiled in, and the library will combine, optionally minify them using <https://github.com/tdewolff/minify>, and generate an output file with the sha256 signature of the file in the filename. Your application can consume the generated byte buffers and handle them as you please, or you can have the library write the files out to a specified directory.
## How do I use it?
@ -22,21 +22,21 @@ package main
import precompiler "github.com/parnic/go-assetprecompiler"
func main() {
precompiler.Compile(precompiler.Config{
Files: []string{
"assets/css/bootstrap.default.css",
"assets/css/font-awesome.css",
"assets/css/application.css",
"assets/js/jquery.js",
"assets/js/popper.js",
"assets/js/bootstrap.js",
"assets/js/moment.js",
"assets/js/application.js",
},
Minify: true,
OutputDir: "assets/",
FilePrefix: "app-",
})
precompiler.Compile(precompiler.Config{
Files: []string{
"assets/css/bootstrap.default.css",
"assets/css/font-awesome.css",
"assets/css/application.css",
"assets/js/jquery.js",
"assets/js/popper.js",
"assets/js/bootstrap.js",
"assets/js/moment.js",
"assets/js/application.js",
},
Minify: true,
OutputDir: "assets/",
FilePrefix: "app-",
})
}
```
@ -45,18 +45,19 @@ Currently only Javascript (.js) and CSS (.css) files are supported.
Config key | Use
-----------|-----
Files | An array of strings representing paths to files you want compiled
Minify | Bool, optionally minify the files with https://github.com/tdewolff/minify
Minify | Bool, optionally minify the files with <https://github.com/tdewolff/minify>
OutputDir | String, the directory you'd like to write the compiled files to (with trailing slash)
FilePrefix | String, what, if anything, should be prefixed onto the output filenames
Note that if an output dir is specified, "css" and "js" subdirectories will be used/created to hold the resulting files. Leaving it blank will cause it to not write any files to disk.
`Compile()` returns `map[FileType]*CompileResult, error` where FileType is one of the supported types, e.g. `precompiler.CSS`, `precompiler.JS` and CompileResult is
```go
type CompileResult struct {
Bytes []byte
Hash string
OutputPath string
Bytes []byte
Hash string
OutputPath string
}
```
@ -73,7 +74,7 @@ Or create a template function to retrieve the correct filenames so you don't hav
## Gin-gonic middleware
There is a https://github.com/gin-gonic/gin middleware available to automatically set a Cache-Control header for infinite lifetime of these assets. You can use it like:
There is a <https://github.com/gin-gonic/gin> middleware available to automatically set a Cache-Control header for infinite lifetime of these assets. You can use it like:
```go
r := gin.New()