@crxjs/vite-plugin 2.0.0-beta.21 → 2.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +6 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import * as lexer from 'es-module-lexer';
|
|
|
11
11
|
import { readFile as readFile$1 } from 'fs/promises';
|
|
12
12
|
import MagicString from 'magic-string';
|
|
13
13
|
import convertSourceMap from 'convert-source-map';
|
|
14
|
-
import { createLogger } from 'vite';
|
|
14
|
+
import { createLogger, version } from 'vite';
|
|
15
15
|
import { readFileSync, existsSync, promises } from 'fs';
|
|
16
16
|
import { createRequire } from 'module';
|
|
17
17
|
import fg from 'fast-glob';
|
|
@@ -1410,7 +1410,7 @@ const pluginHtmlInlineScripts = () => {
|
|
|
1410
1410
|
};
|
|
1411
1411
|
};
|
|
1412
1412
|
|
|
1413
|
-
var loadingPageScript = "const VITE_URL = \"http://localhost:%PORT%\";\ndocument.body.innerHTML = `\n<div\n id=\"app\"\n style=\"\n border: 1px solid #ddd;\n padding: 20px;\n border-radius: 5px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n \"\n >\n <h1 style=\"color: #333\">Vite Dev Mode</h1>\n <p style=\"color: #666\">\n Cannot connect to the Vite Dev Server on <a href=\"${VITE_URL}\">${VITE_URL}</a>\n </p>\n <p style=\"color: #666\">\n Double-check that Vite is working and reload the extension.\n </p>\n <p style=\"color: #666\">\n This page will close when the extension reloads.\n </p>\n <button\n style=\"\n padding: 10px 20px;\n border: none;\n background-color: #007bff;\n color: #fff;\n border-radius: 5px;\n cursor: pointer;\n \"\n >\n Reload Extension\n </button>\n </div>`;\ndocument.body.querySelector(\"button\")?.addEventListener(\"click\", () => {\n chrome.runtime.reload();\n});\nlet tries = 0;\nlet ready = false;\ndo {\n try {\n await fetch(VITE_URL);\n ready = true;\n } catch {\n const timeout = Math.min(100 * Math.pow(2, ++tries), 5e3);\n console.log(`[CRXJS] Vite Dev Server is not available on ${VITE_URL}`);\n console.log(`[CRXJS] Retrying in ${timeout}ms...`);\n await new Promise((resolve) => setTimeout(resolve, timeout));\n }\n} while (!ready);\
|
|
1413
|
+
var loadingPageScript = "const VITE_URL = \"http://localhost:%PORT%\";\ndocument.body.innerHTML = `\n<div\n id=\"app\"\n style=\"\n border: 1px solid #ddd;\n padding: 20px;\n border-radius: 5px;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n \"\n >\n <h1 style=\"color: #333\">Vite Dev Mode</h1>\n <p style=\"color: #666\">\n Cannot connect to the Vite Dev Server on <a href=\"${VITE_URL}\">${VITE_URL}</a>\n </p>\n <p style=\"color: #666\">\n Double-check that Vite is working and reload the extension.\n </p>\n <p style=\"color: #666\">\n This page will close when the extension reloads.\n </p>\n <button\n style=\"\n padding: 10px 20px;\n border: none;\n background-color: #007bff;\n color: #fff;\n border-radius: 5px;\n cursor: pointer;\n \"\n >\n Reload Extension\n </button>\n </div>`;\ndocument.body.querySelector(\"button\")?.addEventListener(\"click\", () => {\n chrome.runtime.reload();\n});\nlet tries = 0;\nlet ready = false;\ndo {\n try {\n await fetch(VITE_URL);\n ready = true;\n } catch {\n const timeout = Math.min(100 * Math.pow(2, ++tries), 5e3);\n console.log(`[CRXJS] Vite Dev Server is not available on ${VITE_URL}`);\n console.log(`[CRXJS] Retrying in ${timeout}ms...`);\n await new Promise((resolve) => setTimeout(resolve, timeout));\n }\n} while (!ready);\nlocation.reload();\n";
|
|
1414
1414
|
|
|
1415
1415
|
var loadingPageHtml = "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <title>Vite Dev Mode</title>\n <script src=\"%SCRIPT%\" type=\"module\"></script>\n </head>\n <body\n style=\"font-family: Arial, sans-serif; padding: 20px; text-align: center\"\n >\n <h1>Vite Dev Mode</h1>\n </body>\n</html>\n";
|
|
1416
1416
|
|
|
@@ -1880,9 +1880,11 @@ const pluginWebAccessibleResources = () => {
|
|
|
1880
1880
|
dynamicScriptMatches.add("https://*/*");
|
|
1881
1881
|
}
|
|
1882
1882
|
if (contentScripts.size > 0) {
|
|
1883
|
+
const viteMajorVersion = parseInt(version.split(".")[0]);
|
|
1884
|
+
const manifestPath = viteMajorVersion > 4 ? ".vite/manifest.json" : "manifest.json";
|
|
1883
1885
|
const viteManifest = parseJsonAsset(
|
|
1884
1886
|
bundle,
|
|
1885
|
-
|
|
1887
|
+
manifestPath
|
|
1886
1888
|
);
|
|
1887
1889
|
const viteFiles = /* @__PURE__ */ new Map();
|
|
1888
1890
|
for (const [, file] of Object.entries(viteManifest))
|
|
@@ -1910,7 +1912,7 @@ const pluginWebAccessibleResources = () => {
|
|
|
1910
1912
|
{ chunks: bundleChunks, files: viteFiles, config }
|
|
1911
1913
|
);
|
|
1912
1914
|
contentScripts.get(key).css = [...css];
|
|
1913
|
-
if (type === "loader")
|
|
1915
|
+
if (type === "loader" || isDynamicScript)
|
|
1914
1916
|
imports.add(fileName);
|
|
1915
1917
|
const resource = {
|
|
1916
1918
|
matches: isDynamicScript ? [...dynamicScriptMatches] : matches,
|