In a few words: with Vite you can build web app (Vue, React, etc.) and libraries containing shared common code between projects.
This post explain how to create a library with Vite as bundler.
I am a builder who codes daily. I have been on the developer journey for the last 11 years, Thus my most projects are around to solve the developers problems and make their life easier,
I am a builder who codes daily. I have been on the developer journey for the last 11 years, Thus my most projects are around to solve the developers problems and make their life easier,
Serial entrepreneur, I'm actually the founder https://svelter.me a platform about svelte where libraries, blog articles and comments all get visibilty through community interactions
Yes it's possible, update the build.lib.entry from type string to array in the vite.config.ts file and add all your input ts files in that array. It will compile and output multiple ts files. Hope that answers your question.
Hey thanks. I first started using Vite for a react project and went with Jest as it was the recommended framework of choice for the react app. And also, Vitest was still in early stage so went with the more popular testing framework and got used to the Jest setup.
Vitest looks promising and the APIs are also lot similar to Jest so will definitely give a try.
We're a place where coders share, stay up-to-date and grow their careers.
In a few words: with Vite you can build web app (Vue, React, etc.) and libraries containing shared common code between projects.
This post explain how to create a library with Vite as bundler.
Great writing, Thanks for the detaled article. Would you mind to add readme description in GitHub repo so one can get to know where to start.
Thanks for the feedback. Have added the readme as suggested please check it out.
Perfect, Thank you.
This is the best written article ever!
This is cool, but the output is a single file, I'd like to compile multiple ts files as tsc does. Is that possible with vite?
I'm new to all of this, so sorry if it's a dumb question.
entry: [
resolve(__dirname, 'src/main.ts'),
resolve(__dirname, 'src/main-2.ts'),
],
Yes it's possible, update the build.lib.entry from type string to array in the vite.config.ts file and add all your input ts files in that array. It will compile and output multiple ts files. Hope that answers your question.
For more info checkout:
vitejs.dev/guide/build.html#librar...
vitejs.dev/config/build-options.ht...
how can we add support for es5 build production? with all popular polyfills.
Thanks for this guide.
Why not use Vitest? It seems very integrated with Vite.
Hey thanks. I first started using Vite for a react project and went with Jest as it was the recommended framework of choice for the react app. And also, Vitest was still in early stage so went with the more popular testing framework and got used to the Jest setup.
Vitest looks promising and the APIs are also lot similar to Jest so will definitely give a try.