I'm trying to use minify library to bundle and minify all my JavaScripts and CSSs, minimum code:
js := bytes.Buffer{}
dat, err := ioutil.ReadFile(fname)
if L.Check(err, `File doesn't exists: `+fname) == nil {
dat, err = min.MinifyBytes(`text/js`, dat)
js.Write(dat)
js.WriteRune(';')
}
But that code failed with err="max buffer exceeded"
when minifying ace.js and jquery.dataTables.js (>400 KB) is this bytes.Buffer
problem? and how to fix this?
According to GoDoc.org, that error is actually thrown from another package by that author .. parse
.
The doc comment says that the input cannot be larger than 4KB in size. Your libraries appear to be much bigger than that.
Luckily, the MaxBuf
variable is exported from that package .. so you should be able to put this line before that code to fix that particular error:
parse.MaxBuf = parse.MaxBuf * 2