Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
main
------

* Recognise an application as Vite-based from any of the six names Vite
resolves its configuration from, rather than only `vite.config.js`,
`vite.config.mjs` and `vite.config.ts`. An application configured in
`vite.config.mts`, `vite.config.cts` or `vite.config.cjs` was taken for a
classic one and served with `ember build --watch`, which a Vite-based
project rejects
* Report the whole `ember build` failure in the `EmberCli::BuildError`
message, instead of only its first line. The line naming the file that
failed to build is rarely the first one the build tool writes, so a parse
Expand Down
14 changes: 12 additions & 2 deletions lib/ember_cli/path_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ module EmberCli
class PathSet
PACKAGE_MANAGERS = %i[npm yarn pnpm].freeze

# Every name Vite resolves its configuration file from. An application
# that keeps its configuration under any of them is Vite-based.
VITE_CONFIG_FILES = %w[
vite.config.js
vite.config.mjs
vite.config.cjs
vite.config.ts
vite.config.mts
vite.config.cts
].freeze

# npm ships with NodeJS, so it has no installation instructions of its own
# to point at when its executable is missing.
INSTALL_INSTRUCTIONS = {
Expand Down Expand Up @@ -55,8 +66,7 @@ def bower_json
# Apps generated with the Vite-based blueprint (`ember-cli >= 6.8`)
# ship a Vite config file at their root.
def vite?
%w[vite.config.mjs vite.config.js vite.config.ts].
any? { |config| root.join(config).exist? }
VITE_CONFIG_FILES.any? { |config| root.join(config).exist? }
end

def ember
Expand Down
20 changes: 7 additions & 13 deletions spec/lib/ember_cli/path_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,14 @@
expect(path_set).not_to be_vite
end

it "is true when the app has a vite.config.mjs" do
app = build_app
create_file(app_root_for(app).join("vite.config.mjs"))
path_set = build_path_set(app: app)

expect(path_set).to be_vite
end

it "is true when the app has a vite.config.js" do
app = build_app
create_file(app_root_for(app).join("vite.config.js"))
path_set = build_path_set(app: app)
EmberCli::PathSet::VITE_CONFIG_FILES.each do |config_file|
it "is true when the app has a #{config_file}" do
app = build_app
create_file(app_root_for(app).join(config_file))
path_set = build_path_set(app: app)

expect(path_set).to be_vite
expect(path_set).to be_vite
end
end
end

Expand Down