bee
bee copied to clipboard
Use go-bindata to pack all the static files to a single binary when build the project
Currently, we can use bee pack to generate a tar.gz which include , if we can pack all the static files into a single binary file it will be convenient for us.
yea, I am still working on that.
@uptoknow I think you should use go bale. It will read all your static files in the specified dirs (*.js, *.css) and generate a *.go file per static file (something like static_js_jquery_xxx.go) inside a bale folder.
If you use a bee.json file, you can add it like this:
...
"bale":{
"dirs": ["static/js", "static/css"]
}
...
@amrfaissal Different than what I request, I want the "bee pack" or some command can help generate a single binary file instead of using go bale to generate the *.go file, and use it some where.
@astaxie Have you already prepare an pr? when you plan to add this? I am glad to help if you don't have more time on it.
@uptoknow it's still on the schedule. not working on it. If you can work on it, that would be awesome.
@astaxie Have a quick look of the code, if we want to implement this feature we need
- When generate the view template, we need read data from go-bindata generate Asset, instead of read from absoluateFilePath
- Which means we need generate the bindata when run ''bee new"
How do you think about this ?
it looks need to implement an interface: TemplateData(path string) ([]byte,error), the default is fileHandler,and if we use the go-bindata we can reimplement the interface.
@astaxie Yeah, I will try to prepare a PR when I can.
@astaxie Met a problem, when we decide to use the go-bindata handler? and how we implement the go-bindata handler based on the current framework, go-bindata is a tool to generate the static go file, and we can use the function Asset("path to the template/file") to generate the data which is difficult for beego to use a after generated function. do you have any idea about this ?
@uptoknow my idea is write a subcommand like bee bale. which all the static files turn into []byte go files, and generate an interface Asset(path) io.Reader. So beego has a config which read from interface which default is set to static. and when we also can overwrite it with the generate interface. That's the general idea.
@uptoknow @astaxie support set Asset func for the template #2402 I've apply the patch , and use
go-bindata.exe -o myview.go views/...
to get sourcecode which contains Asset(..) function. and delete all files in views/ dir. and in my main.go 's init() function set
beego.SetTmplateAssetFunc(Asset)
all compile ok,but execute still get waring
Handler crashed with error can't find templatefile in the views/.....
so, I've no idea now :q
Any tips ?
@uptoknow @astaxie Hi! I'm add views storage configuration Add custom fs template With it, you can use https://github.com/elazarl/go-bindata-assetfs
Can I get a windows binary out of the project. With a .exe extension to deploy on windows server??
If so please let me know how.
Shouldn't this Issue be updated to use Go 1.16 embed package?