Workers
Scripts can be compiled with the bultin compileWorker() method:
Generator.compileWorker(name, src, options, buildOptions);
This works similar to the compileScript() method but with some differences:
- The script is written directly to
outputFolderinstead ofassetFolder(i.e. to the web root). - The output filename does not include a hash.
name: string- Unique name for this script. Used when referencing the script and as the base of the output filename.
src: string- Path to the script entrypoint.
buildOptions: objectOptional-
Options passed to
esbuild.format: "iife" | "cjs" | "esm"Optional- Output format.
define: Record<string, string>Optional- Global identifiers to replace.