diff --git a/pkg/dev_compiler/lib/src/dependency_graph.dart b/pkg/dev_compiler/lib/src/dependency_graph.dart index 6f78db184346..63cbe804fcd8 100644 --- a/pkg/dev_compiler/lib/src/dependency_graph.dart +++ b/pkg/dev_compiler/lib/src/dependency_graph.dart @@ -76,6 +76,8 @@ class SourceGraph { } }); } + + List get resources => _options.resources; } /// A node in the import graph representing a source file. @@ -198,6 +200,9 @@ class HtmlSourceNode extends SourceNode { } var newResources = new Set(); + for (var resource in graph.resources) { + newResources.add(graph.nodeFromUri(uri.resolve(resource))); + } for (var tag in document.querySelectorAll('link[rel="stylesheet"]')) { newResources .add(graph.nodeFromUri(uri.resolve(tag.attributes['href']))); diff --git a/pkg/dev_compiler/lib/src/options.dart b/pkg/dev_compiler/lib/src/options.dart index 6861a9030c6f..7591a881de89 100644 --- a/pkg/dev_compiler/lib/src/options.dart +++ b/pkg/dev_compiler/lib/src/options.dart @@ -26,6 +26,9 @@ class ResolverOptions { /// List of paths used for the multi-package resolver. final List packagePaths; + /// List of additional non-Dart resources to resolve and serve. + final List resources; + /// Whether to infer return types and field types from overriden members. final bool inferFromOverrides; static const inferFromOverridesDefault = true; @@ -60,7 +63,7 @@ class ResolverOptions { static const String implicitHtmlFile = 'index.html'; ResolverOptions({this.useMultiPackage: false, this.packageRoot: 'packages/', - this.packagePaths: const [], + this.packagePaths: const [], this.resources: const [], this.inferFromOverrides: inferFromOverridesDefault, this.inferTransitively: inferTransitivelyDefault, this.onlyInferConstsAndFinalFields: onlyInferConstAndFinalFieldsDefault, @@ -192,6 +195,10 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions { @override final List packagePaths; + /// List of additional non-Dart resources to resolve and serve. + @override + final List resources; + /// Whether to infer types downwards from local context @override final bool inferDownwards; @@ -239,7 +246,7 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions { this.outputDart: false, this.useColors: true, this.covariantGenerics: true, this.relaxedCasts: true, this.useMultiPackage: false, this.packageRoot: 'packages/', - this.packagePaths: const [], + this.packagePaths: const [], this.resources: const [], this.inferDownwards: RulesOptions.inferDownwardsDefault, this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault, this.inferTransitively: ResolverOptions.inferTransitivelyDefault, @@ -304,6 +311,7 @@ CompilerOptions parseOptions(List argv) { useMultiPackage: args['use-multi-package'], packageRoot: args['package-root'], packagePaths: args['package-paths'].split(','), + resources: args['resources'].split(','), inferDownwards: args['infer-downwards'], inferFromOverrides: args['infer-from-overrides'], inferTransitively: args['infer-transitively'], @@ -377,6 +385,8 @@ final ArgParser argParser = new ArgParser() ..addOption('package-paths', help: 'if using the multi-package resolver, the list of directories to\n' 'look for packages in.', defaultsTo: '') + ..addOption('resources', + help: 'Additional resources to serve', defaultsTo: '') ..addFlag('source-maps', help: 'Whether to emit source map files', defaultsTo: true) ..addOption('runtime-dir',