Index: lib/src/server/server.dart |
diff --git a/lib/src/server/server.dart b/lib/src/server/server.dart |
index 555bcedf1ca60a23e51e3f0324e50589c6738530..b5468dc39be08d784a644fc79901ecba70579007 100644 |
--- a/lib/src/server/server.dart |
+++ b/lib/src/server/server.dart |
@@ -254,17 +254,20 @@ class DevServer { |
var out = new Directory(outDir); |
if (!await out.exists()) await out.create(recursive: true); |
- var mainHandler = |
+ var generatedHandler = |
shelf_static.createStaticHandler(outDir, defaultDocument: _entryPath); |
var sourceHandler = shelf_static.createStaticHandler(compiler.inputBaseDir, |
serveFilesOutsidePath: true); |
+ // TODO(vsm): Is there a better builtin way to compose these handlers? |
var topLevelHandler = (shelf.Request request) { |
var path = request.url.path; |
- if (path.endsWith('.dart')) { |
- return sourceHandler(request); |
- } else { |
- return mainHandler(request); |
+ // Prefer generated code |
+ var response = generatedHandler(request); |
+ if (response.statusCode == 404) { |
+ // Fall back on original sources |
+ response = sourceHandler(request); |
} |
+ return response; |
}; |
var handler = const shelf.Pipeline() |