mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
format: run prettify
This commit is contained in:
+19
-19
@@ -1,26 +1,26 @@
|
||||
// vite-plugin-inline-worker-dev.ts
|
||||
import { Plugin } from 'vite'
|
||||
import fs from 'fs/promises'
|
||||
import { build, transform } from 'esbuild'
|
||||
import { Plugin } from "vite";
|
||||
import fs from "fs/promises";
|
||||
import { build, transform } from "esbuild";
|
||||
|
||||
export default function InlineWorkerDevPlugin(): Plugin {
|
||||
return {
|
||||
name: 'vite:inline-worker-dev',
|
||||
name: "vite:inline-worker-dev",
|
||||
async load(id) {
|
||||
if (id.includes('?inlineWorker')) {
|
||||
const [cleanPath] = id.split('?')
|
||||
console.log('cleanPath', cleanPath)
|
||||
const code = await fs.readFile(cleanPath, 'utf-8')
|
||||
if (id.includes("?inlineWorker")) {
|
||||
const [cleanPath] = id.split("?");
|
||||
console.log("cleanPath", cleanPath);
|
||||
const code = await fs.readFile(cleanPath, "utf-8");
|
||||
const result = await build({
|
||||
entryPoints: [cleanPath],
|
||||
bundle: true,
|
||||
write: false,
|
||||
platform: 'browser',
|
||||
format: 'iife',
|
||||
target: 'esnext',
|
||||
})
|
||||
|
||||
const workerCode = result.outputFiles[0].text
|
||||
platform: "browser",
|
||||
format: "iife",
|
||||
target: "esnext",
|
||||
});
|
||||
|
||||
const workerCode = result.outputFiles[0].text;
|
||||
|
||||
const workerBlobCode = `
|
||||
const code = ${JSON.stringify(workerCode)};
|
||||
@@ -28,10 +28,10 @@ export default function InlineWorkerDevPlugin(): Plugin {
|
||||
const blob = new Blob([code], { type: 'application/javascript' });
|
||||
return new Worker(URL.createObjectURL(blob), { type: 'module' });
|
||||
}
|
||||
`
|
||||
return workerBlobCode
|
||||
`;
|
||||
return workerBlobCode;
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user