File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,13 @@ export default defineNuxtModule<ModuleOptions>({
168168 // Transpile runtime
169169 nuxt . options . build . transpile . push ( resolve ( 'runtime' ) )
170170
171+ // Ensure `@plausible-analytics/tracker` is pre-bundled by Vite.
172+ // The package only has a `module` field (no `main` or `exports`), which
173+ // causes Vite's resolver to fail in certain environments (e.g. Vitest).
174+ nuxt . options . vite . optimizeDeps ||= { }
175+ nuxt . options . vite . optimizeDeps . include ||= [ ]
176+ nuxt . options . vite . optimizeDeps . include . push ( '@plausible-analytics/tracker' )
177+
171178 if ( nuxt . options . runtimeConfig . public . plausible . proxy ) {
172179 const proxyBaseEndpoint = withLeadingSlash ( nuxt . options . runtimeConfig . public . plausible . proxyBaseEndpoint )
173180 const hasUserProvidedProxyBase = [ ...nuxt . options . serverHandlers , ...nuxt . options . devServerHandlers ] . some ( handler => handler . route ?. startsWith ( proxyBaseEndpoint ) )
You can’t perform that action at this time.
0 commit comments