Setup example worker
This commit is contained in:
+2
-1
@@ -17,7 +17,8 @@
|
||||
"suspicious": {
|
||||
"noTsIgnore": "off",
|
||||
"noAssignInExpressions": "off",
|
||||
"noFallthroughSwitchClause": "warn"
|
||||
"noFallthroughSwitchClause": "warn",
|
||||
"noGlobalAssign": "warn"
|
||||
},
|
||||
"correctness": {
|
||||
"useParseIntRadix": "off",
|
||||
|
||||
@@ -85,3 +85,12 @@ function animate(timestamp: number): void {
|
||||
|
||||
animate(delta);
|
||||
})();
|
||||
|
||||
const worker = new Worker(new URL("./worker.ts", import.meta.url), {
|
||||
type: "module",
|
||||
});
|
||||
|
||||
worker.onmessage = (event) => {
|
||||
console.log(event.data);
|
||||
};
|
||||
worker.postMessage("foo");
|
||||
|
||||
+7
-1
@@ -18,7 +18,13 @@ function devTools(): Plugin {
|
||||
|
||||
export default defineConfig({
|
||||
server: { host, port, hmr: false },
|
||||
build: { target: "esnext" },
|
||||
build: {
|
||||
target: "esnext",
|
||||
main: `${root}index.html`,
|
||||
lib: {
|
||||
entry: `${root}worker.ts`,
|
||||
},
|
||||
},
|
||||
test: {
|
||||
include: ["./engine/**/*.test.ts"],
|
||||
environment: "jsdom",
|
||||
|
||||
Reference in New Issue
Block a user