Skip to content

Vite trying to bundle node methods instead of webCrypto #587

Closed Locked Answered by bruceharrison1984
bruceharrison1984 asked this question in Q&A
Discussion options

You must be logged in to vote

As is tradition, as soon as I posted this I found my answer. Vite seems to fumble on selecting the correct entry point, so it ends up using something other than browser.

vitejs/vite#2329

Forcibly telling Vite to use the browser version only when deploying via alias looks something like this:

import { defineConfig } from 'vite';
import sonik from 'sonik/vite';
import pages from '@sonikjs/cloudflare-pages';
import { fileURLToPath, URL } from 'url';

export default defineConfig(({command}) => ({ 
  plugins: [sonik(), pages()],
  resolve: {
    alias: [
      {
        find: '@',
        replacement: fileURLToPath(new URL('./app', import.meta.url)),
      },
      ...(command === 'build' ? [{

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@panva
Comment options

panva Oct 4, 2023
Maintainer

Answer selected by bruceharrison1984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants