diff --git a/CHANGELOG.md b/CHANGELOG.md index 515746f1..ad812509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/ember_cli/path_set.rb b/lib/ember_cli/path_set.rb index 1a261754..06386afd 100644 --- a/lib/ember_cli/path_set.rb +++ b/lib/ember_cli/path_set.rb @@ -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 = { @@ -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 diff --git a/spec/lib/ember_cli/path_set_spec.rb b/spec/lib/ember_cli/path_set_spec.rb index 7e737d84..406b9a47 100644 --- a/spec/lib/ember_cli/path_set_spec.rb +++ b/spec/lib/ember_cli/path_set_spec.rb @@ -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