Documentation ¶
Overview ¶
Package concatjs provides a simple way of serving JavaScript sources in development.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServeConcatenatedJS ¶
func ServeConcatenatedJS(manifestPath string, root string, preScripts []string, postScripts []string, fs FileSystem) http.Handler
ServeConcatenatedJS returns an http.Handler that serves the JavaScript files listed in manifestPath in one concatenated, eval separated response body.
This greatly speeds up development load times due to fewer HTTP requests, but still for easy debugging by giving the eval'ed fragments URLs through sourceURL comments.
Example usage:
http.Handle("/app_combined.js", concatjs.ServeConcatenatedJS("my/app/web_srcs.MF", ".", [], [], nil))
Relative paths in the manifest are resolved relative to the path given as root.
Types ¶
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache caches a set of files in memory and provides a single method, WriteFiles(), that streams them out in the concatjs format.
func NewFileCache ¶
func NewFileCache(root string, fs FileSystem) *FileCache
NewFileCache constructs a new FileCache. Relative paths in the cache are resolved relative to root. fs injects file system access, and will use the real file system if nil.
type FileSystem ¶
type FileSystem interface {
// contains filtered or unexported methods
}
FileSystem is the interface to reading files from disk. It's abstracted into an interface to allow tests to replace it.