Set publicPath in production webpack config

This commit is contained in:
Ken-Håvard Lieng 2018-11-07 01:35:53 +01:00
parent ca222ff10d
commit ed40b956b7
5 changed files with 45 additions and 43 deletions

View file

@ -19,7 +19,7 @@
<link rel="preload" href="/font/RobotoMono-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<% if cssPath != "" { %>
<link href="/<%== cssPath %>" rel="stylesheet">
<link href="<%== cssPath %>" rel="stylesheet">
<% } %>
<link rel="icon" href="data:;base64,=">
@ -35,7 +35,7 @@
<% } %>
<% for _, script := range scripts { %>
<script src="/<%== script %>"></script>
<script src="<%== script %>"></script>
<% } %>
</body>

View file

@ -10,7 +10,7 @@ import (
func IndexTemplate(w io.Writer, data *indexData, cssPath string, inlineScript string, scripts []string) error {
io.WriteString(w, "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"theme-color\" content=\"#222\"><title>Dispatch</title><link rel=\"preload\" href=\"/font/fontello.woff2?48901973\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/RobotoMono-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/Montserrat-Regular.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/Montserrat-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\"><link rel=\"preload\" href=\"/font/RobotoMono-Bold.woff2\" as=\"font\" type=\"font/woff2\" crossorigin=\"anonymous\">")
if cssPath != "" {
io.WriteString(w, "<link href=\"/")
io.WriteString(w, "<link href=\"")
io.WriteString(w, cssPath )
io.WriteString(w, "\" rel=\"stylesheet\">")
}
@ -23,7 +23,7 @@ io.WriteString(w, "<script id=\"env\" type=\"application/json\">")
io.WriteString(w, "</script>")
}
for _, script := range scripts {
io.WriteString(w, "<script src=\"/")
io.WriteString(w, "<script src=\"")
io.WriteString(w, script )
io.WriteString(w, "\"></script>")
}

View file

@ -41,7 +41,7 @@ type h2PushAsset struct {
func newH2PushAsset(name string) h2PushAsset {
return h2PushAsset{
path: "/" + name,
path: name,
hash: strings.Split(name, ".")[1],
}
}
@ -121,19 +121,20 @@ func (d *Dispatch) initFileServer() {
ignoreAssets := []string{
manifest["runtime.js"],
manifest["boot.js"],
"sw.js",
manifest["sw.js"],
}
outer:
for _, assetPath := range manifest {
for _, ignored := range ignoreAssets {
if assetPath == ignored {
continue
continue outer
}
}
file := &File{
Path: assetPath,
Asset: assetPath + ".br",
Asset: strings.TrimLeft(assetPath, "/") + ".br",
ContentType: contentTypes[filepath.Ext(assetPath)],
CacheControl: longCacheControl,
Compressed: true,
@ -211,7 +212,7 @@ func decompressAsset(data []byte) []byte {
}
func decompressedAsset(name string) []byte {
asset, err := assets.Asset(name + ".br")
asset, err := assets.Asset(strings.TrimLeft(name, "/") + ".br")
if err != nil {
log.Fatal(err)
}