vite build Command: Build Frontends in CI
vite build creates an optimized production bundle using Rollup under the hood.
vite is a modern frontend build tool: a fast dev server plus a Rollup-based production build. In CI you almost always run vite build, which type-agnostically bundles, minifies, and hashes assets into a dist directory.
Common flags
vite build- produce a production build into dist/--mode production|staging- select the .env mode and define vars-c/--config FILE- use a specific vite config--outDir DIR- output directory (default dist)--base /path/- public base path for deployed assets--sourcemap- emit source maps for the build--emptyOutDir- clear the out dir before building
Example in CI
Run a production build with a staging mode and source maps in CI:
shell
vite build --mode staging --sourcemap --outDir distCommon errors in CI
- [vite]: Rollup failed to resolve import "X" - missing dep or wrong path/alias
- Could not load /path (imported by Y) - file missing or case-sensitive path mismatch
- Build failed: Transform failed - a syntax error in source
- JavaScript heap out of memory - large build; raise Node memory limit
Key takeaways
vite buildis the CI command; the dev server is for local use only.--modepicks the env file andimport.meta.envdefine values.- "Rollup failed to resolve import" is the most common CI build failure.
Related guides
rollup Command: Bundle Libraries in CIrollup bundles ES modules into optimized output. Reference for -c, -i, -o, --format, --sourcemap, --watch, an…
webpack-cli Command: Bundle in CIwebpack-cli runs webpack builds. Reference for --mode, --config, --entry, --output-path, --analyze, and the w…
esbuild Command: Bundle & Compile in CIesbuild is a fast Go-based bundler/compiler. Reference for --bundle, --outfile, --minify, --platform, --targe…