feat: remove rollup options & improve clean up

This commit is contained in:
allanice001
2025-09-23 12:59:15 +01:00
parent 182ad023e7
commit a59550bd96
17 changed files with 16 additions and 20113 deletions

View File

@@ -13,7 +13,7 @@ RUN npm i -g yarn pnpm
WORKDIR /src WORKDIR /src
COPY . . COPY . .
RUN make swagger && make build RUN make clean && make swagger && make ui && make build
################################# #################################

View File

@@ -3,6 +3,7 @@ GOINSTALL := $(GOCMD) install
BIN ?= autoglue BIN ?= autoglue
MAIN ?= main.go MAIN ?= main.go
UI_DIR ?= ui UI_DIR ?= ui
UI_DEST_DIR ?= internal/ui
SWAG := $(shell command -v swag 2>/dev/null) SWAG := $(shell command -v swag 2>/dev/null)
GMU := $(shell command -v go-mod-upgrade 2>/dev/null) GMU := $(shell command -v go-mod-upgrade 2>/dev/null)
@@ -68,7 +69,7 @@ build: prepare ui swagger
clean: clean:
@echo ">> Cleaning artifacts..." @echo ">> Cleaning artifacts..."
@rm -rf $(BIN) docs/swagger.* docs/docs.go $(UI_DIR)/dist @rm -rf $(BIN) docs/swagger.* docs/docs.go $(UI_DEST_DIR)/dist $(UI_DIR)/dist $(UI_DIR)/node_modules
dev: swagger dev: swagger
@echo ">> Starting Vite (frontend) and Go API (backend)..." @echo ">> Starting Vite (frontend) and Go API (backend)..."

View File

@@ -37,7 +37,7 @@ services:
- postgres:postgres - postgres:postgres
env_file: .env env_file: .env
environment: environment:
DATABASE_URL: postgres://$DB_USER:$DB_PASSWORD@postgres:5432/$DB_NAME PGWEB_DATABASE_URL: postgres://$DB_USER:$DB_PASSWORD@postgres:5432/$DB_NAME
depends_on: depends_on:
- postgres - postgres

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -20,10 +20,8 @@ func NewRouter() http.Handler {
r.Use(cors.Handler(cors.Options{ r.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{ AllowedOrigins: []string{
"http://localhost:5173", "http://*:5173",
"http://127.0.0.1:5173", "http://*:8080",
"http://localhost:8080",
"http://127.0.0.1:8080",
}, },
AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"}, AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Content-Type", "content-type", "Authorization", "authorization", "X-Org-ID", "x-org-id"}, AllowedHeaders: []string{"Content-Type", "content-type", "Authorization", "authorization", "X-Org-ID", "x-org-id"},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,18 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AutoGlue</title>
<script type="module" crossorigin src="/assets/index-DSxuk_EI.js"></script>
<link rel="modulepreload" crossorigin href="/assets/router-CANfZtzM.js">
<link rel="modulepreload" crossorigin href="/assets/vendor-DvippHRz.js">
<link rel="modulepreload" crossorigin href="/assets/radix-DRmH1vcw.js">
<link rel="modulepreload" crossorigin href="/assets/icons-B5E6SSBo.js">
<link rel="stylesheet" crossorigin href="/assets/index-CHoyJPs-.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -14,7 +14,7 @@ import (
// NOTE: Vite outputs to ui/dist with assets in dist/assets. // NOTE: Vite outputs to ui/dist with assets in dist/assets.
// If you add more nested folders in the future, include them here too. // If you add more nested folders in the future, include them here too.
//go:embed dist/* dist/assets/* //go:embed dist
var distFS embed.FS var distFS embed.FS
// spaFileSystem serves embedded dist/ files with SPA fallback to index.html // spaFileSystem serves embedded dist/ files with SPA fallback to index.html
@@ -37,7 +37,8 @@ func (s spaFileSystem) Open(name string) (fs.File, error) {
// BUT only if it's not obviously a static asset extension // BUT only if it's not obviously a static asset extension
ext := strings.ToLower(filepath.Ext(name)) ext := strings.ToLower(filepath.Ext(name))
switch ext { switch ext {
case ".js", ".css", ".map", ".json", ".txt", ".ico", ".png", ".jpg", ".jpeg", ".svg", ".webp", ".gif", ".woff", ".woff2": case ".js", ".css", ".map", ".json", ".txt", ".ico", ".png", ".jpg", ".jpeg",
".svg", ".webp", ".gif", ".woff", ".woff2", ".ttf", ".otf", ".eot", ".wasm":
return nil, fs.ErrNotExist return nil, fs.ErrNotExist
} }
@@ -89,8 +90,14 @@ func SPAHandler() (http.Handler, error) {
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable") w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
} }
info, _ := f.Stat()
modTime := time.Now()
if info != nil {
modTime = info.ModTime()
}
// Serve content // Serve content
http.ServeContent(w, r, filePath, time.Now(), file{f}) http.ServeContent(w, r, filePath, modTime, file{f})
}), nil }), nil
} }

View File

@@ -2,7 +2,6 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AutoGlue</title> <title>AutoGlue</title>
</head> </head>

View File

@@ -34,21 +34,6 @@ export default defineConfig({
chunkSizeWarningLimit: 1000, chunkSizeWarningLimit: 1000,
outDir: "../internal/ui/dist", outDir: "../internal/ui/dist",
emptyOutDir: true, emptyOutDir: true,
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes("node_modules")) return
if (id.includes("react-router")) return "router"
if (id.includes("@radix-ui")) return "radix"
if (id.includes("lucide-react") || id.includes("react-icons")) return "icons"
if (id.includes("recharts") || id.includes("d3")) return "charts"
if (id.includes("date-fns") || id.includes("dayjs")) return "dates"
return "vendor"
},
},
},
}, },
optimizeDeps: { optimizeDeps: {
include: ["react", "react-dom", "react-router-dom"], include: ["react", "react-dom", "react-router-dom"],