mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00

* removed react-app type instead use vite. * removed index.html from public since vite uses it from root: read more: https://vitejs.dev/guide/#index-html-and-project-root * yarn.lock update. * added vite config file. With commented rollUp option if we want the build to be called build but using default stuff for now. * updated tsconfig to use vite and include vite.config.ts * changed package json build commands to use vite. * for some reason there is an error in vite config when we put project as tsconfig.json. * build.go updated to use the new dist folder. * refactored as well updated to use dist and web.AssetHandler again. * Fixed issue forcing the frontend to be reloaded for all routes to work if logged in fresh without reloading it will always go back to dashboard. * updated it to use the new function; need to fix the Index for baseUrl I believe, if enabled it works except logs route will crash due to cors. * refactored and default port to 7474, don't think we need the rollUpOptions. * added tmp/ to ignore . * init air.toml, for dev hot reloading both app and backend. https://github.com/cosmtrek/air run it using air but make sure it's in PATH * updated the start command to build and watch for changes, works great with air. * revert * added proxy for vite config. To be used for dev. * fix: This fixes #117 Propagation bug. * refactor: I think this should fix it, when logs route etc getting accessed usually it throws error but by getting rid of the catch-all it should work as intended, since web.RegisterHandler(r) will catch the unmatched ones. * Moved outside static, keep it in public root folder. * refactor to support the changes * Added support for PWA, autoinject which auto updates when there is new "version" instead of prompting user. * fix colour and added the assets. * chore: yarn lock and remove logos. * chore: remove logos, don't think we need em. * chore:added dist folder. --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
91 lines
No EOL
2.8 KiB
TypeScript
91 lines
No EOL
2.8 KiB
TypeScript
import { fileURLToPath, URL } from "node:url";
|
|
|
|
import react from "@vitejs/plugin-react-swc";
|
|
import { VitePWA } from "vite-plugin-pwa";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
// https://vitejs.dev/config/
|
|
export default ({ mode }: { mode: any }) => {
|
|
// early load .env file
|
|
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
|
|
// import.meta.env.VITE_NAME available here with: process.env.VITE_NAME
|
|
|
|
return defineConfig({
|
|
base: "",
|
|
plugins: [react(), VitePWA({
|
|
registerType: "autoUpdate",
|
|
injectRegister: "auto",
|
|
includeAssets: [
|
|
"favicon.svg",
|
|
"favicon.ico",
|
|
"robots.txt",
|
|
"apple-touch-icon.png",
|
|
"manifest.webmanifest",
|
|
"assets/**/*"
|
|
],
|
|
manifest: {
|
|
name: "autobrr",
|
|
short_name: "autobrr",
|
|
description: "Automation for downloads.",
|
|
theme_color: "#141415",
|
|
background_color: "#141415",
|
|
icons: [
|
|
{
|
|
src: "logo192.png",
|
|
sizes: "192x192",
|
|
type: "image/png"
|
|
},
|
|
{
|
|
src: "logo512.png",
|
|
sizes: "512x512",
|
|
type: "image/png"
|
|
},
|
|
|
|
{
|
|
src: "logo512.png",
|
|
sizes: "512x512",
|
|
type: "image/png",
|
|
purpose: "any maskable"
|
|
}
|
|
],
|
|
start_url: "/",
|
|
display: "standalone"
|
|
|
|
},
|
|
workbox: {
|
|
globPatterns: ["**/*.{js,css,html,svg}"],
|
|
sourcemap: true
|
|
}
|
|
})],
|
|
resolve: {
|
|
alias: [
|
|
{ find: "@", replacement: fileURLToPath(new URL("./src/", import.meta.url)) },
|
|
{ find: "@app", replacement: fileURLToPath(new URL("./src/", import.meta.url)) },
|
|
{ find: "@components", replacement: fileURLToPath(new URL("./src/components", import.meta.url)) },
|
|
{ find: "@forms", replacement: fileURLToPath(new URL("./src/forms", import.meta.url)) },
|
|
{ find: "@hooks", replacement: fileURLToPath(new URL("./src/hooks", import.meta.url)) },
|
|
{ find: "@api", replacement: fileURLToPath(new URL("./src/api", import.meta.url)) },
|
|
{ find: "@screens", replacement: fileURLToPath(new URL("./src/screens", import.meta.url)) },
|
|
{ find: "@utils", replacement: fileURLToPath(new URL("./src/utils", import.meta.url)) },
|
|
{ find: "@types", replacement: fileURLToPath(new URL("./src/types", import.meta.url)) },
|
|
{ find: "@domain", replacement: fileURLToPath(new URL("./src/domain", import.meta.url)) }
|
|
]
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
hmr: {
|
|
overlay: true
|
|
},
|
|
proxy: {
|
|
"/api": {
|
|
target: "http://127.0.0.1:7474/",
|
|
changeOrigin: true,
|
|
secure: false
|
|
}
|
|
}
|
|
},
|
|
build: {
|
|
manifest: true,
|
|
sourcemap: true
|
|
}
|
|
});
|
|
}; |