Build a Vite application with vite build - #681
Merged
Merged
Conversation
`Command#build` drove every build through `ember build`. In a Vite-based project that command is on its way out: `ember build --help` there describes itself as a "Vestigial command in Vite-based projects. Use the `build` script from package.json instead", and has dropped every option but `--environment`, `--suppress-sizes` and `--output-path`. It refuses `--watch` and `--watcher` rather than forwarding them. Build such an application with `vite build` instead, which is what the blueprint's own `build` script runs. `Command#build` picks the command from the blueprint, and the two builders sit side by side so that what each blueprint needs stays visible. The flags follow from what the gem needs of a build: * `--mode` carries what `--environment` carried, from the same `build_environment` * `--outDir` carries what `--output-path` carried, the directory Rails serves the application from * `--emptyOutDir` keeps the directory cleared between builds. It lies outside the Ember application, where Vite leaves stale files in place unless asked * `--logLevel error` stands in for `--silent`, quieting the progress output while leaving errors visible Running `vite build` directly rather than the `build` script through a package manager is deliberate: the gem has to pass `--outDir`, and forwarding flags to a script is not portable — npm needs `--` before them, while pnpm passes that `--` on to the script, where the flags arrive as literal arguments and the build silently writes to `dist` instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tricknotes
marked this pull request as ready for review
September 11, 2026 17:23
This was referenced Sep 11, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Command#builddrove every build throughember build. In a Vite-based project that command is on its way out. Its own help text says so:It now declares only
--environment,--suppress-sizesand--output-path, and refuses--watchand--watcherrather than forwarding them (lib/commands/build.js). The blueprint's own script is"build": "vite build"(ember-app-blueprint).So build a Vite application with
vite build.Command#buildpicks the command from the blueprint, and the two builders sit side by side so what each one needs stays visible.The flags
--environment--modebuild_environment--output-path--outDir--emptyOutDir--silent--logLevel error--emptyOutDiris not an improvement, it is parity. Dropping aSTALE.txtinto the output directory and rebuilding:STALE.txtember build --output-pathvite build --outDir --emptyOutDirvite build --outDirWhy not run the
buildscript through a package managerThe gem has to pass
--outDir, and forwarding flags to a package.json script is not portable. Measured against the same application, with the command each package manager actually ran:npm run build -- <flags>vite build --outDir … --mode … --emptyOutDirnpm run build <flags>vite build /tmp/out developmentpnpm build <flags>vite build --outDir … --mode … --emptyOutDirpnpm run build -- <flags>vite build -- --outDir … --mode …dist— the separator reaches the scriptnpm needs
--, pnpm must not have it, and the pnpm failure is silent. Callingvitedirectly avoids the whole question, and keeps theDependencyErrorthatPathSet#viteraises when the executable is missing.Verification
Against the sandbox application (
ember-cli7.2.0,vite8.2.2):rake ember:compileexits 0, running…/node_modules/.bin/vite build --mode 'development' --outDir '…/tmp/ember-cli/apps/frontend' --emptyOutDirember build --environment development --output-pathproduced —diffof the two file listings, with content hashes normalised, is emptyBuilt project successfully. Stored in ".../tmp/compat-prebuild")--mode production) writesindex.htmlplus every asset it referencesTests
bin/rspec spec/lib/ember_cli/command_spec.rb— 14 examples, 0 failures, including three for the Vite buildbin/rspec spec/lib— 2 failures, both (app_spec.rb:192,app_spec.rb:200) failing identically onmain; they neednode_modulesinstalled to find theemberbinaryember testis untouched: it is not vestigial in a Vite project and still works, sorake ember:testkeeps running it. The blueprint has begun moving that totestem cidirectly, which is worth its own look later.🤖 Generated with Claude Code