Skip to content

Commit

Permalink
feat: option to override Vite's namedExports (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Oct 30, 2023
1 parent bdd88e3 commit b4aa0a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-shirts-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vite-imagetools': minor
---

feat: option to override Vite's namedExports
2 changes: 1 addition & 1 deletion packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function imagetools(userOptions: Partial<VitePluginOptions> = {}): Plugin
}

return dataToEsm(await outputFormat(outputMetadatas), {
namedExports: viteConfig.json?.namedExports ?? true,
namedExports: pluginOptions.namedExports ?? viteConfig.json?.namedExports ?? true,
compact: !!viteConfig.build.minify ?? false,
preferConst: true
})
Expand Down
9 changes: 8 additions & 1 deletion packages/vite/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,15 @@ export interface VitePluginOptions {
resolveConfigs?: ResolveConfigs

/**
* Wether to remove potentially private metadata from the image, such as exif tags etc.
* Whether to remove potentially private metadata from the image, such as exif tags etc.
* @default true
*/
removeMetadata: boolean

/**
* Whether to generate named exports.
* Takes precedence over Vite's `json.namedExports`
* @default undefined
*/
namedExports?: undefined
}

0 comments on commit b4aa0a5

Please sign in to comment.