From 1474e50f7253745ea632c2ef6e562609fe0d423c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez?= Date: Thu, 21 Mar 2024 20:15:45 +0100 Subject: [PATCH] feat(injectManifest): add sw build env options and change vite configuration (#690) --- src/options.ts | 10 ++++++++++ src/types.ts | 34 +++++++++++++++++++++++++++++++++- src/vite-build.ts | 11 ++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/options.ts b/src/options.ts index 23b61617..d50faea6 100644 --- a/src/options.ts +++ b/src/options.ts @@ -125,6 +125,7 @@ export async function resolveOptions(ctx: PWAPluginContext): Promise + + /** + * Environment options. + * + * @since v0.19.6 + */ + envOptions?: { + /** + * Configure Vite `envDir` option. + * + * @default Vite `envDir`. + */ + envDir?: UserConfig['envDir'] + /** + * Configure Vite `envPrefix` option. + * + * @default Vite `envPrefix`. + */ + envPrefix?: UserConfig['envPrefix'] + } } export interface PWAIntegration { @@ -94,6 +114,14 @@ export interface PWAIntegration { viteOptions: ResolvedConfig, options: Partial, ) => void | Promise + /** + * Allow integrations to configure Vite options for custom service worker build. + * + * @param options Vite options for custom service worker build. + * @see src/vite-build.ts module + * @since v0.19.6 + */ + configureCustomSWViteBuild?: (options: InlineConfig) => void | Promise } /** @@ -388,6 +416,10 @@ export interface ResolvedVitePWAOptions extends Required