How to setup a ViteJS project to build to an output directory

A step by step guide on creating a ReactJS, ViteJS, GLSL and ThreeJS project that outputs to a build to the public directory.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 12/11/2023 at 11:29
Last Updated on 12/14/2023 at 10:54
<p>Two flowers that represent ReactJS and ViteJS side by side. Beneath them sits the text "Setup Build."</p>

A step by step guide on creating a ReactJS, ViteJS, GLSL and ThreeJS project that outputs to a build to the public directory.

SubscribeReact, ThreeJS & GLSL Resources

The proposed solution can be found on the main branch of our Open Source React, Typescript & ViteJS Starter Project.

git clone git@github.com:delasign/reactjs-3js-vitejs-starter-project.git
View Repository

Step One: Setup the Project

<p>A screenshot of Chrome showing the shader on a plane and how the shader looks different thanks to the change in colors that we created using the GUI.</p>

Follow the tutorial below to learn how to setup a Typescript & ViteJS project that works with a GLSL shader whose R, G, B color values can be adapted using dat.gui.

How to use dat.gui with ReactJS and ThreeJS

Step Two: Update the Vite Config

<p>A screenshot of VSCode showing how we setup the outDir within the vite.config.ts file. This config is setup to output the build to the "public" folder at the root of the project.</p>

In the vite.config.ts file, update the defineConfig to include an outDir that matches the path of where you would like the build to be outputted to.

Step Three: Test

<p>A screenshot of Terminal showing how the build succeeds and outputs to the public folder.</p>

In Terminal, with the current directory set to that of the project, run yarn build and confirm that the build outputs to the right folder.

Looking to learn more about ReactJS, ViteJS and ThreeJS ?

Search our blog to find educational content on learning how to use ReactJS, ViteJS and ThreeJS.

Search our BlogReact, ThreeJS & GLSL Resources

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe