0

I am building react app using vite.

I run the following command, the preview show everything is working.

npm run build
npm run preview

But when I transfer to the IIS or tomcat server, it show blank page without any error.

Not sure what is happen?

The only different when I deploy to web server I put it into a folder example C:\inetpub\wwwroot\example

Below is my vite.config.ts:

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';
import { fileURLToPath, URL } from 'url';
// https://vitejs.dev/config/
export default defineConfig({
  server: {
    port: 3000
  },
  plugins: [
    react(), viteTsconfigPaths(), svgrPlugin()
  ],
  define: {
    "global": {},
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
    mainFields: [],
  },
  css: {
    preprocessorOptions: {
      scss: {
        // example : additionalData: `@import "./src/styles/variables";`
        // There is need to include the .scss file extensions.
        // additionalData: `@import "./src/styles/variables";`,
      },
    },
  },
  base: './',
});
Alvin
  • 8,219
  • 25
  • 96
  • 177

1 Answers1

0

It sounds like your server doesn't know where to find the .html file. Did you configure it to use /wwwroot/example/public as the root?

Try placing the contents of /public (the .js, .css, .html that the build process created) directly inside the /wwwroot folder. So then it would just look like /wwwroot/index.html.

Wesley LeMahieu
  • 2,296
  • 1
  • 12
  • 8