Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x breaks vite pre-rendering #1403

Open
2 tasks done
nathanstitt opened this issue May 1, 2024 · 0 comments
Open
2 tasks done

4.x breaks vite pre-rendering #1403

nathanstitt opened this issue May 1, 2024 · 0 comments

Comments

@nathanstitt
Copy link

Describe the bug

The 4.x series of releases cause build failures with Vite (and Vike) when using the "prerendering: true" option. The error DOES NOT occur using 3.9.5 but occurs on 4.0.0

The error is:

[vike][Warning] Vite's development server was instantiated while the environment is set to be a production environment by process.env.NODE_ENV === "production" which is contradictory, see https://vike.dev/NODE_ENV

To replicate the error:

  • npm init vike@latest
  • npm install @vanilla-extract/vite-plugin
  • Apply this commit or the below commands:
  • edit package.json to add a "name" field (build will fail unless a project has a name)
  • edit vite.config.ts to add vanilla-extract:
import react from '@vitejs/plugin-react'
import vike from 'vike/plugin'
import { UserConfig } from 'vite'
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';

const config: UserConfig = {
  plugins: [vanillaExtractPlugin(), react(), vike({ prerender: true })]
}

export default config
  • run npm run build

Reproduction

https://github.com/nathanstitt/vanilla-extract-vite-ssg

System Info

System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 336.00 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.5.0 - /usr/local/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 9.8.0 - /usr/local/bin/npm
    pnpm: 8.15.2 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.93
    Safari: 17.3.1
  npmPackages:
    @vanilla-extract/vite-plugin: ^4.0 => 4.0.9
    vite: ^5.0.10 => 5.2.10

Used Package Manager

npm

Logs

dist/server/entry.mjs                                5.13 kB
✓ built in 65ms
vike v0.4.171 pre-rendering HTML...
2:30:26 PM [vike][Warning] Vite's development server was instantiated while the environment is set to be a production environment by process.env.NODE_ENV === "production" which is contradictory, see https://vike.dev/NODE_ENV
Error: [vike@0.4.171][Bug] You stumbled upon a Vike bug. Go to https://github.com/vikejs/vike/issues/new and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).
    at initGlobalContext (file:///private/tmp/vt/node_modules/vike/dist/esm/node/runtime/globalContext.js:90:9)
    at runPrerender (file:///private/tmp/vt/node_modules/vike/dist/esm/node/prerender/runPrerender.js:80:11)
    at runPrerenderFromAutoFullBuild (file:///private/tmp/vt/node_modules/vike/dist/esm/node/prerender/runPrerender.js:47:9)
    at triggerFullBuild (file:///private/tmp/vt/node_modules/vike/dist/esm/node/plugin/plugins/autoFullBuild.js:92:9)
    at Object.handler (file:///private/tmp/vt/node_modules/vike/dist/esm/node/plugin/plugins/autoFullBuild.js:31:25)
    at async Promise.all (index 0)
    at PluginDriver.hookParallel (file:///private/tmp/vt/node_modules/rollup/dist/es/shared/node-entry.js:19706:9)
    at file:///private/tmp/vt/node_modules/rollup/dist/es/shared/node-entry.js:20703:13

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant