From ffaf5c9e9d6b36800bdf37f977ac373a628dd394 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Tue, 20 Aug 2024 15:40:04 +0200 Subject: [PATCH] add vite replace html plugin for graphiql plugin explorer (#3742) * add vite replace html plugin for graphiql plugin explorer * fix build --- .../graphiql-plugin-explorer/example.html | 15 +++---- .../graphiql-plugin-explorer/vite.config.mts | 41 +++++++++++++++++-- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/packages/graphiql-plugin-explorer/example.html b/packages/graphiql-plugin-explorer/example.html index 7d07347f1a..3e5d223eee 100644 --- a/packages/graphiql-plugin-explorer/example.html +++ b/packages/graphiql-plugin-explorer/example.html @@ -38,30 +38,27 @@ > - +
-
Loading…
+
Loading...
- `; + + return { + name: 'html-replace-umd-with-src', + transformIndexHtml: { + order: 'pre', + handler(html) { + const start = ''; + const end = ''; + const contentToReplace = html.slice( + html.indexOf(start) + start.length, + html.indexOf(end), + ); + return html.replace(contentToReplace, htmlForVite); + }, + }, + }; +}