Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MimeTypeAllow = map[string]string{
".js": "application/javascript",
".json": "application/json",
".woff": "font/woff",
".woff2": "font/woff2",
".ttf": "font/ttf",
".mjs": "text/javascript",
".html": "text/html",
".txt": "text/plain",
".css": "text/css",
".csv": "text/csv",
".md": "text/markdown",
".gif": "image/gif",
".ico": "image/x-icon",
".jpeg": "image/jpeg",
".jpg": "image/jpeg",
".png": "image/png",
".tiff": "image/tiff",
".tif": "image/tiff",
".svg": "image/svg+xml",
}
var MimeTypeReplace = map[string]bool{ ".js": true, ".json": true, ".mjs": true, ".css": true, }
var RegJs = regexp.MustCompile(`['"][\w\.\-_/]+?(\.js)['"]`)
var RegServiceW = regexp.MustCompile(`(serviceWorker\.register\()['"][\w\-\._/]+?(\.js)['"]`)
var RegStatic = regexp.MustCompile(`['"][\w.\-/ ]+?(\.(?:js|json|woff2?|ttf|mjs|txt|css|md|gif|ico|jpe?g|png|tiff?|svg))['"]`) //matchear todos las url de js,css,mjs y svg para que sean reemplazados
['"][\w\.\-_/ ]+?((\.js)|(\.json)|(\.woff)|(\.woff2)|(\.ttf)|(\.mjs)|(\.txt)|(\.css)|(\.md)|(\.gif)|(\.ico)|(\.jpeg)|(\.jpg)|(\.png)|(\.tiff)|(\.tif)|(\.svg))['"]`) //matchear todos las url de js,css,mjs y svg para que sean reemplazados regJs: regex to find .js files,regServiceW: regex to find service workers definitions regStatic: regex to find static files urls, files ending in .js,.json,.woff,.woff2,.ttf,.json,.mjs,.txt,.css,.md,.gif,.ico,.jpeg,.jpg, .png, .tiff, .tif, .svg
var RegURL = regexp.MustCompile("[^a-zA-Z0-9]+")
Functions ¶
func CompressBrotli ¶
func CompressZstd ¶
func CorrectFormatCss ¶
before, the script didn't catch this format: url(../img/icons/ic-search.svg) so I will just convert it to url("../img/icons/ic-search.svg")
Types ¶
type HTML ¶
type HTML struct {
Path string
Content []byte
ContentBR []byte
Checksum string
ServiceWorkers map[string]bool
DependsFullPath map[string]bool
DataGenerate bool
}
HTML contains all info about html like if there is any service worker
type Static ¶
type Static struct {
Path string //it's full path
Name string
ChangeContent bool
Extension string
MimeType string
Obfuscate bool
Content staticInfo
ContentObf staticInfo
DependsFullPath map[string]bool
}
Static contains info about the static file like the checksum, its content, and so on