Skip to content

Commit

Permalink
feat: allow passing just the manifest path instead of a function
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 committed Nov 8, 2021
1 parent dff41fa commit ae14216
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demos/vanilla/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
},
plugins: [
browserExtension({
manifest: () => readJsonFile(root("src/manifest.json")),
manifest: root("src/manifest.json"),
assets: "assets",
additionalInputs: ["content-scripts/script1/index.ts"],
watchFilePaths: [root("src/manifest.json")],
Expand Down
10 changes: 5 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ type Manifest = any;

interface BrowserExtensionPluginOptions {
/**
* A function that returns your manifest as a JS object. It's a function so that the manifest can
* be updated on hot reload!
* The path to your manifest.json or a function that returns your manifest as a JS object. It's a
* function that returns a generated or dynamic javascript object representing the manifest
*
* @example
* () => require("./path/to/manifest.json")
* () => readJsonFile("./path/to/manifest.json")
*/
manifest: (() => Manifest) | (() => Promise<Manifest>);
manifest: string | (() => Manifest) | (() => Promise<Manifest>);

/**
* This path is where the manifest will be written to, and it is relative to Vite's output path
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function browserExtension<T>(
async function getManifest(): Promise<Manifest> {
return typeof options.manifest === "function"
? options.manifest()
: options.manifest;
: readJsonFile(options.manifest);
}

function transformManifestInputs(manifestWithTs: any): {
Expand Down

0 comments on commit ae14216

Please sign in to comment.