Getting an error when run "vite preview" (use Vite + React + Antd)

Viewed 508

I am building a library with vite, react and ant design.

The build command vite build runs fine without warnings, but when I run vite preview command, then I give an error. I do not know why this is happening.

[![enter image description here][1]][1]

index.b71761d7.js:4879 TypeError: jsxDevRuntime.exports.jsxDEV is not a function
    at Provider (index.b71761d7.js:31334:48)
    at Ch (index.b71761d7.js:3752:8)
    at ck (index.b71761d7.js:6267:12)
    at bk (index.b71761d7.js:5797:12)
    at ak (index.b71761d7.js:5790:5)
    at Tj (index.b71761d7.js:5773:7)
    at Lj (index.b71761d7.js:5541:26)
    at Jg (index.b71761d7.js:5389:52)
    at lk (index.b71761d7.js:6631:3)
    at index.b71761d7.js:6719:7

Please help me, thank you very much!

This is my vite.config.js file

import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';

export default ({ mode }) => {
  // Load app-level env vars to node-level env vars.
  console.log('Running on environment ' + mode);
  process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };

  return defineConfig({
    plugins: [
      react({
        babel: {
          plugins: [['@babel/plugin-transform-react-jsx', { runtime: 'automatic' }]],
        },
      }),
    ],
    resolve: {
      alias: [{ find: /^~/, replacement: '' }],
    },
    css: {
      preprocessorOptions: {
        less: {
          modifyVars: {
            // 'primary-color': '#282F7E',
            'primary-color': '#F58220',
            // 'text-color': '#282F7E',
            'btn-border-radius-base': '6px',
            'btn-border-radius-sm': '6px',
            'control-border-radius': '6px',
            'tag-border-radius': '6px',
            dark: true,
            compact: true,
          },
          javascriptEnabled: true,
        },
      },
    },
    optimizeDeps: {
      include: ['@ant-design/icons'],
    },
    server: {
      port: 3711,
    },
    preview: {
      port: 8711,
    },
    build: {
      chunkSizeWarningLimit: 1000,
      outDir: 'build',
    },
  });
};


  [1]: https://i.stack.imgur.com/gw1Wf.png
0 Answers
Related