diff --git a/index.ts b/index.ts
index 8d6878b..78b3476 100644
--- a/index.ts
+++ b/index.ts
@@ -3,7 +3,7 @@ import type { Plugin as VitePlugin } from "vite";
 
 // Utility to invoke a given sbt task and fetch its output
 function printSbtTask(task: string, cwd?: string): Promise<string> {
-  const args = ["--batch", "-no-colors", "-Dsbt.supershell=false", `print ${task}`];
+  const args = ["--batch", "-no-colors", "-Dsbt.supershell=false", `set ${task} / aggregate := false; print ${task}`];
   const options: SpawnOptions = {
     cwd: cwd,
     stdio: ['ignore', 'pipe', 'inherit'],
diff --git a/test/plugin.test.ts b/test/plugin.test.ts
index f48f503..9cc8be8 100644
--- a/test/plugin.test.ts
+++ b/test/plugin.test.ts
@@ -87,6 +87,48 @@ describe("scalaJSPlugin", () => {
       .toBeNull();
   }, testOptions);
 
+  it("works with a project that aggregates other ScalaJS enabled projects) (development)", async () => {
+    const [plugin, fakePluginContext] = setup({
+      projectID: "aggregatedProject",
+    });
+
+    await plugin.configResolved.call(undefined, { mode: MODE_DEVELOPMENT });
+    await plugin.buildStart.call(fakePluginContext, {});
+
+    const path = normalizeSlashes(await plugin.resolveId.call(fakePluginContext, 'scalajs:main.js')) ;
+
+    expect(path)
+      .toContain('/testproject/aggregated-project/target/scala-3.2.2/aggregatedproject-fastopt/main.js');
+
+    expect(path)
+      .toMatch(/^[^ \t]/); // Should not start with whitespace
+
+    expect(await plugin.resolveId.call(fakePluginContext, 'scalajs/main.js'))
+      .toBeNull();
+  }, testOptions);
+
+  it("works with a project that aggregates other ScalaJS enabled projects) (production)", async () => {
+    const [plugin, fakePluginContext] = setup({
+      projectID: "aggregatedProject",
+    });
+
+    await plugin.configResolved.call(undefined, { mode: MODE_PRODUCTION });
+    await plugin.buildStart.call(fakePluginContext, {});
+
+    const path = normalizeSlashes(await plugin.resolveId.call(fakePluginContext, 'scalajs:main.js')) ;
+
+    console.log("Found path: " + path);
+
+    expect(path)
+      .toContain('/testproject/aggregated-project/target/scala-3.2.2/aggregatedproject-opt/main.js');
+
+    expect(path)
+      .toMatch(/^[^ \t]/); // Should not start with whitespace
+
+    expect(await plugin.resolveId.call(fakePluginContext, 'scalajs/main.js'))
+      .toBeNull();
+  }, testOptions);
+
   it("works with a custom URI prefix (development)", async () => {
     const [plugin, fakePluginContext] = setup({
       uriPrefix: "customsjs",
diff --git a/test/testproject/aggregated-project/src/main/scala/aggregatedproject/AggregatedProject.scala b/test/testproject/aggregated-project/src/main/scala/aggregatedproject/AggregatedProject.scala
new file mode 100644
index 0000000..e33e8e3
--- /dev/null
+++ b/test/testproject/aggregated-project/src/main/scala/aggregatedproject/AggregatedProject.scala
@@ -0,0 +1,5 @@
+package aggregatedproject
+
+@main def AggregatedProject(): Unit =
+  println("hello")
+end AggregatedProject
diff --git a/test/testproject/build.sbt b/test/testproject/build.sbt
index 781256d..10f8eae 100644
--- a/test/testproject/build.sbt
+++ b/test/testproject/build.sbt
@@ -11,6 +11,11 @@ lazy val otherProject = project.in(file("other-project"))
   .enablePlugins(ScalaJSPlugin)
   .settings(commonSettings)
 
+lazy val aggregatedProject = project.in(file("aggregated-project"))
+  .enablePlugins(ScalaJSPlugin)
+  .settings(commonSettings)
+  .aggregate(otherProject)
+
 // This project does not link because it has no main method
 lazy val invalidProject = project.in(file("invalid-project"))
   .enablePlugins(ScalaJSPlugin)