1
0
Эх сурвалжийг харах

Add vite

Changes according to Vite defaults:

- Move index.html to root
- Replace `%PUBLIC_URL%` with plain `/`
nimbleghost 2 жил өмнө
parent
commit
e21327cec5
6 өөрчлөгдсөн 2181 нэмэгдсэн , 15615 устгасан
  1. 1 2
      Makefile
  2. 1 1
      server/server_test.go
  3. 6 5
      web/index.html
  4. 2154 15602
      web/package-lock.json
  5. 5 5
      web/package.json
  6. 14 0
      web/vite.config.js

+ 1 - 2
Makefile

@@ -129,8 +129,7 @@ web-build:
 		&& rm -rf ../server/site \
 		&& mv build ../server/site \
 		&& rm \
-			../server/site/config.js \
-			../server/site/asset-manifest.json
+			../server/site/config.js
 
 web-deps:
 	cd web && npm install

+ 1 - 1
server/server_test.go

@@ -219,7 +219,7 @@ func TestServer_StaticSites(t *testing.T) {
 
 	rr = request(t, s, "GET", "/mytopic", "", nil)
 	require.Equal(t, 200, rr.Code)
-	require.Contains(t, rr.Body.String(), `<meta name="robots" content="noindex, nofollow"/>`)
+	require.Contains(t, rr.Body.String(), `<meta name="robots" content="noindex, nofollow" />`)
 
 	rr = request(t, s, "GET", "/docs", "", nil)
 	require.Equal(t, 301, rr.Code)

+ 6 - 5
web/public/index.html → web/index.html

@@ -15,7 +15,7 @@
     <meta name="apple-mobile-web-app-status-bar-style" content="#317f6f" />
 
     <!-- Favicon, see favicon.io -->
-    <link rel="icon" type="image/png" href="%PUBLIC_URL%/static/images/favicon.ico" />
+    <link rel="icon" type="image/png" href="/static/images/favicon.ico" />
 
     <!-- Previews in Google, Slack, WhatsApp, etc. -->
     <meta property="og:type" content="website" />
@@ -26,15 +26,15 @@
       property="og:description"
       content="ntfy lets you send push notifications via scripts from any computer or phone. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy."
     />
-    <meta property="og:image" content="%PUBLIC_URL%/static/images/ntfy.png" />
+    <meta property="og:image" content="/static/images/ntfy.png" />
     <meta property="og:url" content="https://ntfy.sh" />
 
     <!-- Never index -->
     <meta name="robots" content="noindex, nofollow" />
 
     <!-- Style overrides & fonts -->
-    <link rel="stylesheet" href="%PUBLIC_URL%/static/css/app.css" type="text/css" />
-    <link rel="stylesheet" href="%PUBLIC_URL%/static/css/fonts.css" type="text/css" />
+    <link rel="stylesheet" href="/static/css/app.css" type="text/css" />
+    <link rel="stylesheet" href="/static/css/fonts.css" type="text/css" />
   </head>
   <body>
     <noscript>
@@ -43,6 +43,7 @@
       subscribe.
     </noscript>
     <div id="root"></div>
-    <script src="%PUBLIC_URL%/config.js"></script>
+    <script src="/config.js"></script>
+    <script type="module" src="/src/index.jsx"></script>
   </body>
 </html>

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 2154 - 15602
web/package-lock.json


+ 5 - 5
web/package.json

@@ -3,10 +3,9 @@
   "version": "1.0.0",
   "private": true,
   "scripts": {
-    "start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
-    "build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
-    "test": "DISABLE_ESLINT_PLUGIN=true react-scripts test",
-    "eject": "DISABLE_ESLINT_PLUGIN=true react-scripts eject",
+    "start": "NODE_OPTIONS=\"--enable-source-maps\" vite",
+    "build": "vite build",
+    "serve": "vite preview",
     "format": "prettier . --write",
     "format:check": "prettier . --check",
     "lint": "eslint --report-unused-disable-directives --ext .js,.jsx ./src/"
@@ -30,6 +29,7 @@
     "stacktrace-js": "^2.0.2"
   },
   "devDependencies": {
+    "@vitejs/plugin-react": "^4.0.0",
     "eslint": "^8.41.0",
     "eslint-config-airbnb": "^19.0.4",
     "eslint-config-prettier": "^8.8.0",
@@ -38,7 +38,7 @@
     "eslint-plugin-react": "^7.32.2",
     "eslint-plugin-react-hooks": "^4.6.0",
     "prettier": "^2.8.8",
-    "react-scripts": "^5.0.0"
+    "vite": "^4.3.8"
   },
   "browserslist": {
     "production": [

+ 14 - 0
web/vite.config.js

@@ -0,0 +1,14 @@
+/* eslint-disable import/no-extraneous-dependencies */
+import { defineConfig } from "vite";
+import react from "@vitejs/plugin-react";
+
+export default defineConfig(() => ({
+  build: {
+    outDir: "build",
+    assetsDir: "static/media"
+  },
+  server: {
+    port: 3000,
+  },
+  plugins: [react()],
+}));

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно