Skip to content

Commit

Permalink
fix: use @rollup/plugin-replace for typeof replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Nov 20, 2023
1 parent 9508abf commit bf9d500
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@nuxt/postcss8": "^1.1.3",
"@nuxt/schema": "3.8.1",
"@nuxt/ui-templates": "^1.3.1",
"@rollup/plugin-replace": "^5.0.5",
"@unhead/ssr": "^1.8.4",
"@unhead/vue": "^1.8.4",
"@vitejs/plugin-legacy": "^5.0.0",
Expand Down
17 changes: 10 additions & 7 deletions packages/bridge/src/vite/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import createVuePlugin from '@vitejs/plugin-vue2'
import { logger } from '@nuxt/kit'
import type { InlineConfig } from 'vite'
import { joinURL, withoutLeadingSlash, withTrailingSlash } from 'ufo'
import replace from '@rollup/plugin-replace'
import { initViteNodeServer } from '../vite-node'
import { mergeConfig, createServer, build } from './stub-vite.cjs'
import { wpfs } from './utils/wpfs'
Expand Down Expand Up @@ -48,12 +49,7 @@ export async function buildServer (ctx: ViteBuildContext) {
'process.client': false,
'process.static': false,
// use `process.client` instead. `process.browser` is deprecated
'process.browser': false,
'typeof window': '"undefined"',
'typeof document': '"undefined"',
'typeof navigator': '"undefined"',
'typeof location': '"undefined"',
'typeof XMLHttpRequest': '"undefined"'
'process.browser': false
},
cacheDir: resolve(ctx.nuxt.options.rootDir, 'node_modules/.cache/vite/server'),
resolve: {
Expand Down Expand Up @@ -101,7 +97,14 @@ export async function buildServer (ctx: ViteBuildContext) {
},
plugins: [
jsxPlugin(),
vuePlugin
vuePlugin,
replace({
'typeof window': '"undefined"',
'typeof document': '"undefined"',
'typeof navigator': '"undefined"',
'typeof location': '"undefined"',
'typeof XMLHttpRequest': '"undefined"'
})
]
} as ViteOptions)

Expand Down
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bf9d500

Please sign in to comment.