-
How do I define an constant variable with EsBuild? I tried the following: export const pwaConfig: Partial<VitePWAOptions> = {
registerType: 'autoUpdate',
devOptions: {
enabled: true,
type: 'module',
},
strategies: 'injectManifest',
injectManifest: {
swSrc: 'pwa/customServiceWorker.ts',
// precache these files.
globPatterns: ['**/*.{js,css,html,svg,woff,woff2,png}'],
},
integration: {
configureCustomSWViteBuild: (options) => {
throw 'test'; // <- never reached!
if (!options.esbuild) {
options.esbuild = {};
}
options.esbuild.define ??= {};
options.esbuild.define.__FIREBASE_CONFIG = `'${process.env.PUBLIC_FIREBASE_CONFIG}'`;
},
},
} But it seems I am not understanding what |
Beta Was this translation helpful? Give feedback.
Answered by
userquin
Oct 4, 2024
Replies: 1 comment 12 replies
-
Are you using any integration (Nuxt, SvelteKit, Astro...)? |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should:
/// <reference types="vite/client" />
to your service worker.env
file and prefix public entries withVITE_
and useimport.meta.env.VITE_XXX
: there is no way to access anyprocess.env
variable from the service worker (Nuxt will not expose anyvite.define
norruntimeConfig.public
inimport.meta.env
(also checkedvite.define.envPrefix = ['VITE_', 'NUXT_']
)https://stackblitz.com/edit/github-4afvcv-xu75vp?file=nuxt.config.ts,pwa%2FcustomServiceWorker.ts,.env