mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-01 01:30:46 +08:00
Replace custom rewrite middleware with vite plugin
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Generated
+33
-63
@@ -22,7 +22,6 @@
|
||||
"@walletconnect/types": "^1.8.0",
|
||||
"@walletconnect/utils": "^1.8.0",
|
||||
"buffer": "^6.0.3",
|
||||
"connect-history-api-fallback": "^2.0.0",
|
||||
"eip1193-provider": "1.0.1",
|
||||
"ethereum-blockies": "^0.1.1",
|
||||
"ethers": "^5.7.1",
|
||||
@@ -45,8 +44,6 @@
|
||||
"@rsksmart/mock-web3-provider": "^1.0.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^1.0.8",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"@types/connect-history-api-fallback": "^1.3.5",
|
||||
"@types/express-serve-static-core": "^4.17.31",
|
||||
"@types/lodash": "^4.14.186",
|
||||
"@types/sanitize-html": "^2.6.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
||||
@@ -61,6 +58,7 @@
|
||||
"svelte-check": "^2.9.1",
|
||||
"typescript": "^4.8.4",
|
||||
"vite": "^3.0.3",
|
||||
"vite-plugin-rewrite-all": "^1.0.0",
|
||||
"vitest": "^0.23.4"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1924,27 +1922,6 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/connect-history-api-fallback": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz",
|
||||
"integrity": "sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/express-serve-static-core": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/express-serve-static-core": {
|
||||
"version": "4.17.31",
|
||||
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz",
|
||||
"integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/qs": "*",
|
||||
"@types/range-parser": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/form-data": {
|
||||
"version": "0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz",
|
||||
@@ -2000,12 +1977,6 @@
|
||||
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/range-parser": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
|
||||
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/sanitize-html": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/sanitize-html/-/sanitize-html-2.6.2.tgz",
|
||||
@@ -3401,9 +3372,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/connect-history-api-fallback": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz",
|
||||
"integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA==",
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz",
|
||||
"integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.8"
|
||||
}
|
||||
@@ -8402,6 +8374,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vite-plugin-rewrite-all": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/vite-plugin-rewrite-all/-/vite-plugin-rewrite-all-1.0.0.tgz",
|
||||
"integrity": "sha512-XScNU1F73ImgsNQUuDTBd09r8nSz8Umr5PVhfmGJ8FTrFvfcci+P1pD7lT5BIdua75ZoNZGfHgdNYwnZB4cszQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"connect-history-api-fallback": "^1.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vite": "^2.0.0 || ^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vitest": {
|
||||
"version": "0.23.4",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-0.23.4.tgz",
|
||||
@@ -9990,27 +9977,6 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/connect-history-api-fallback": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz",
|
||||
"integrity": "sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/express-serve-static-core": "*",
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/express-serve-static-core": {
|
||||
"version": "4.17.31",
|
||||
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.31.tgz",
|
||||
"integrity": "sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"@types/qs": "*",
|
||||
"@types/range-parser": "*"
|
||||
}
|
||||
},
|
||||
"@types/form-data": {
|
||||
"version": "0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz",
|
||||
@@ -10066,12 +10032,6 @@
|
||||
"integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/range-parser": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
|
||||
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/sanitize-html": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/sanitize-html/-/sanitize-html-2.6.2.tgz",
|
||||
@@ -11113,9 +11073,10 @@
|
||||
}
|
||||
},
|
||||
"connect-history-api-fallback": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz",
|
||||
"integrity": "sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA=="
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz",
|
||||
"integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==",
|
||||
"dev": true
|
||||
},
|
||||
"convert-source-map": {
|
||||
"version": "1.8.0",
|
||||
@@ -14816,6 +14777,15 @@
|
||||
"rollup": "^2.75.6"
|
||||
}
|
||||
},
|
||||
"vite-plugin-rewrite-all": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/vite-plugin-rewrite-all/-/vite-plugin-rewrite-all-1.0.0.tgz",
|
||||
"integrity": "sha512-XScNU1F73ImgsNQUuDTBd09r8nSz8Umr5PVhfmGJ8FTrFvfcci+P1pD7lT5BIdua75ZoNZGfHgdNYwnZB4cszQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"connect-history-api-fallback": "^1.6.0"
|
||||
}
|
||||
},
|
||||
"vitest": {
|
||||
"version": "0.23.4",
|
||||
"resolved": "https://registry.npmjs.org/vitest/-/vitest-0.23.4.tgz",
|
||||
|
||||
+1
-3
@@ -19,8 +19,6 @@
|
||||
"@rsksmart/mock-web3-provider": "^1.0.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^1.0.8",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"@types/connect-history-api-fallback": "^1.3.5",
|
||||
"@types/express-serve-static-core": "^4.17.31",
|
||||
"@types/lodash": "^4.14.186",
|
||||
"@types/sanitize-html": "^2.6.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
||||
@@ -35,6 +33,7 @@
|
||||
"svelte-check": "^2.9.1",
|
||||
"typescript": "^4.8.4",
|
||||
"vite": "^3.0.3",
|
||||
"vite-plugin-rewrite-all": "^1.0.0",
|
||||
"vitest": "^0.23.4"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -53,7 +52,6 @@
|
||||
"@walletconnect/types": "^1.8.0",
|
||||
"@walletconnect/utils": "^1.8.0",
|
||||
"buffer": "^6.0.3",
|
||||
"connect-history-api-fallback": "^2.0.0",
|
||||
"eip1193-provider": "1.0.1",
|
||||
"ethereum-blockies": "^0.1.1",
|
||||
"ethers": "^5.7.1",
|
||||
|
||||
+2
-22
@@ -2,9 +2,7 @@
|
||||
import path from "path";
|
||||
import type { UserConfig } from "vite";
|
||||
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||
import type { ViteDevServer } from "vite";
|
||||
import history from "connect-history-api-fallback";
|
||||
import type { Request, Response } from "express-serve-static-core";
|
||||
import pluginRewriteAll from "vite-plugin-rewrite-all";
|
||||
|
||||
const config: UserConfig = {
|
||||
optimizeDeps: {
|
||||
@@ -29,7 +27,7 @@ const config: UserConfig = {
|
||||
dev: process.env.NODE_ENV !== "production",
|
||||
},
|
||||
}),
|
||||
rewriteAll(),
|
||||
pluginRewriteAll(),
|
||||
],
|
||||
server: {
|
||||
port: 3000,
|
||||
@@ -64,21 +62,3 @@ if (process.env.VITEST || process.env.Cypress) {
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
||||
function rewriteAll() {
|
||||
return {
|
||||
name: "rewrite-all",
|
||||
configureServer(server: ViteDevServer) {
|
||||
return () => {
|
||||
const handler = history({
|
||||
disableDotRule: true,
|
||||
rewrites: [{ from: /\/$/, to: () => "/index.html" }],
|
||||
});
|
||||
|
||||
server.middlewares.use((req, res, next) => {
|
||||
handler(req as Request, res as Response, next);
|
||||
});
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user