diff --git a/.gitignore b/.gitignore index 3c5405969..750b8834d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,8 @@ web/public/js/bundle.js web/public/css/*.* web/public/html/**/*.* web/public/fonts/*.* -web2/dist web2/.nyc_output +web2/dist/**/* config.json .DS_Store node_modules/ diff --git a/Taskfile.yml b/Taskfile.yml index 81d88f4fc..e97b8eee9 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -127,6 +127,7 @@ tasks: - db/db-packr.go - api/api-packr.go cmds: + - mkdir -p web2/dist - go run util/version_gen/generator.go {{ if .TAG }}{{ .TAG }}{{ else }}{{ if .SEMAPHORE_VERSION }}{{ .SEMAPHORE_VERSION }}{{ else }}{{ .BRANCH }}-{{ .SHA }}-{{ .TIMESTAMP }}{{ if .DIRTY }}-dirty{{ end }}{{ end }}{{end}} - packr vars: diff --git a/api/router.go b/api/router.go index a42bc52de..da051d154 100644 --- a/api/router.go +++ b/api/router.go @@ -16,15 +16,8 @@ import ( "github.com/russross/blackfriday" ) -var publicAssets packr.Box - -func getPublicAssetsPath() string { - if util.Config != nil && util.Config.OldFrontend { - return "../web/public" - } - - return "../web2/dist" -} +var publicAssets = packr.NewBox("../web/public") +var publicAssets2 = packr.NewBox("../web2/dist") //JSONMiddleware ensures that all the routes respond with Json, this is added by default to all routes func JSONMiddleware(next http.Handler) http.Handler { @@ -58,8 +51,6 @@ func notFoundHandler(w http.ResponseWriter, r *http.Request) { // Route declares all routes func Route() *mux.Router { - publicAssets = packr.NewBox(getPublicAssetsPath()) - r := mux.NewRouter().StrictSlash(true) r.NotFoundHandler = http.HandlerFunc(servePublic) @@ -271,7 +262,18 @@ func servePublic(w http.ResponseWriter, r *http.Request) { split := strings.Split(path, ".") suffix := split[len(split)-1] - res, err := publicAssets.MustBytes(path) + fmt.Println("path") + fmt.Println(path) + + var res []byte + var err error + + if util.Config.OldFrontend { + res, err = publicAssets.MustBytes(path) + } else { + res, err = publicAssets2.MustBytes(path) + } + if err != nil { notFoundHandler(w, r) return diff --git a/web2/.gitignore b/web2/.gitignore deleted file mode 100644 index 403adbc1e..000000000 --- a/web2/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -.DS_Store -node_modules -/dist - - -# local env files -.env.local -.env.*.local - -# Log files -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# Editor directories and files -.idea -.vscode -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw?