question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vite + React build fails

See original GitHub issue
Screen Shot 2021-09-16 at 10 56 45 Screen Shot 2021-09-16 at 10 57 15

vite.config.ts

import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
import tsconfigPaths from 'vite-tsconfig-paths'
import Icons from 'unplugin-icons/vite'
import { visualizer } from 'rollup-plugin-visualizer'

export default defineConfig({
  plugins: [
    reactRefresh(),
    tsconfigPaths(),
    Icons({ compiler: 'jsx', jsx: 'react' }),
    visualizer()
  ]
})

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "./src",
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": false,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react",
    "types": ["unplugin-icons/types/react"]
  },
  "include": ["./src"]
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
userquincommented, Sep 16, 2021

@oferitz if you’re using vite just try vite build, should work (vite should transform before building).

0reactions
oferitzcommented, Sep 16, 2021

@userquin Thanks, finally we understand each other 😃 so just that you know running with tsc will fail and that’s what my issue is all about, Maybe it worth taking a look on why. Thank you so much for the quick response and the time you took trying to help 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run build error with vite (typescript) - Stack Overflow
My environment works when I am in develop mode, but I get some react-router-dom errors when I start the build via vite.
Read more >
Vite build fails when library has React code in a ".ts" file #13
Describe the bug Vite build for our application started failing after upgrading @vitejs/plugin-react from 2.0.0 to 2.0.1.
Read more >
Build error when deploying React + Vite - Netlify Support Forums
Hello,. I am deploying my site to Netlify by way of Github and I am receiving and error when I try to deploy...
Read more >
Troubleshooting - Vite
Also if there is a dependency loop, a full reload will happen. To solve this, try removing the loop. Build #. Built file...
Read more >
Minified React error in production with Vite.js - Fredrik Bergqvist
So I converted it to TypeScript and ripped out the old babel/webpack build system and installed Vite to handle all the builds. Everything...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found