Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork186
-
Below I have listed the file structure I have in my project as well as the Vite config file, if I create a component in the
exportdefaultfunctionGrid(){return(<div>I am a grid</div>// ^^^^ This JSX tag requires 'React' to be in scope, but it could not be found.ts(2874)// This error only happens if this component is in the /lib folder, but it does not occur in the /src folder)} .└──lib/├──components/│└──Button/│└──index.tsx└──main.ts
import{defineConfig}from'vite'importvuefrom'@vitejs/plugin-vue'import{libInjectCss}from'vite-plugin-lib-inject-css'import{resolve}from'path'import{globSync}from'glob'importpathfrom'node:path';import{fileURLToPath}from'node:url';importdtsfrom'vite-plugin-dts'importvueJsxfrom'@vitejs/plugin-vue-jsx'// https://vite.dev/config/exportdefaultdefineConfig({plugins:[vue(),vueJsx(),libInjectCss(),dts({tsconfigPath:resolve(__dirname,"tsconfig.lib.json")})],esbuild:{jsxFactory:'h',jsxFragment:'Fragment',},build:{copyPublicDir:false,lib:{entry:resolve(__dirname,'lib/main.ts'),formats:['es']},rollupOptions:{external:['vue'],input:Object.fromEntries(globSync('lib/**/*.{ts,tsx}',{ignore:['lib/**/*.d.ts']}).map(file=>[path.relative('lib',file.slice(0,file.length-path.extname(file).length)),fileURLToPath(newURL(file,import.meta.url))])),output:{assetFileNames:'assets/[name][extname]',entryFileNames:'[name].js'}}}}) |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 0 comments
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment