setting `global` in `vite.define` breaks build
See original GitHub issueEnvironment
- Operating System:
Darwin
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0-rc.2
- Package Manager:
yarn@3.1.1
- Builder:
vite
- User Config:
ssr
,runtimeConfig
,typescript
,css
,buildModules
,alias
- Runtime Modules:
-
- Build Modules:
@vueuse/nuxt@8.4.2
,@intlify/nuxt3@0.1.10
Reproduction
Simply set these settings, and execute npx nuxi generate
or nuxi build
.
// nuxt.config.ts
export default defineConfig({
// ...
alias: {
// ...
'./runtimeConfig': './runtimeConfig.browser',
},
vite: {
// ...
define: {
"global": {},
}
}
});
Describe the bug
More precisely, it seems that the global variable conflicts with nuxt’s middleware or something similar.
However, this error does not appear when running nuxi dev
.
Additional context
This global parameter is the currently standard flag that is added to solve runtime issues with AWS Amplify. See #2308 for the related discussion.
Logs
------------------------------
67: nuxtApp._activeRoute = reactive(activeRoute);
68: nuxtApp._middleware = nuxtApp._middleware || {
69: global: [],
^
70: named: {}
71: };
ERROR Unexpected token (Note that you need plugins to import files that are not JavaScript)
------------------------------
Issue Analytics
- State:
- Created a year ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Building for Production - Vite
When it is time to deploy your app for production, simply run the vite build command. By default, it uses <root>/index.html as the...
Read more >API - esbuild
#Define. Supported by: Transform | Build. This feature provides a way to replace global identifiers with constant expressions. It can be a way...
Read more >defining global variables with vite development - Stack Overflow
define is a config that tells Vite how to perform a search-and-replace. It can only replace one string for another (objects cannot be...
Read more >Docs • Svelte
SvelteKit utilizes Vite to build your code and handle server-side rendering (SSR). ... <script> export let person; // this will only set `name`...
Read more >Adding Vite to Your Existing Web App | CSS-Tricks
We also create the following vite.config.ts right next to the index.html file in the project directory. import { defineConfig } ...
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @danielroe, is this an issue that is a high priority? It’s open for about a half year, I am not complaining whatsoever, just interested if it is something that can be fixed easily or that it is difficult to fix.
Thanks 😃
Posted a work-around here: https://github.com/nuxt/framework/discussions/2308#discussioncomment-2766426