Skip to content

Commit

Permalink
Fixes #196 - Enable resources to be served
Browse files Browse the repository at this point in the history
  • Loading branch information
vsmenon committed May 22, 2015
1 parent 980c090 commit 32e4f40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/dev_compiler/lib/src/dependency_graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class SourceGraph {
}
});
}

List<String> get resources => _options.resources;
}

/// A node in the import graph representing a source file.
Expand Down Expand Up @@ -198,6 +200,9 @@ class HtmlSourceNode extends SourceNode {
}

var newResources = new Set<ResourceSourceNode>();
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'])));
Expand Down
14 changes: 12 additions & 2 deletions pkg/dev_compiler/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ResolverOptions {
/// List of paths used for the multi-package resolver.
final List<String> packagePaths;

/// List of additional non-Dart resources to resolve and serve.
final List<String> resources;

/// Whether to infer return types and field types from overriden members.
final bool inferFromOverrides;
static const inferFromOverridesDefault = true;
Expand Down Expand Up @@ -60,7 +63,7 @@ class ResolverOptions {
static const String implicitHtmlFile = 'index.html';

ResolverOptions({this.useMultiPackage: false, this.packageRoot: 'packages/',
this.packagePaths: const <String>[],
this.packagePaths: const <String>[], this.resources: const <String>[],
this.inferFromOverrides: inferFromOverridesDefault,
this.inferTransitively: inferTransitivelyDefault,
this.onlyInferConstsAndFinalFields: onlyInferConstAndFinalFieldsDefault,
Expand Down Expand Up @@ -192,6 +195,10 @@ class CompilerOptions implements RulesOptions, ResolverOptions, JSCodeOptions {
@override
final List<String> packagePaths;

/// List of additional non-Dart resources to resolve and serve.
@override
final List<String> resources;

/// Whether to infer types downwards from local context
@override
final bool inferDownwards;
Expand Down Expand Up @@ -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 <String>[],
this.packagePaths: const <String>[], this.resources: const <String>[],
this.inferDownwards: RulesOptions.inferDownwardsDefault,
this.inferFromOverrides: ResolverOptions.inferFromOverridesDefault,
this.inferTransitively: ResolverOptions.inferTransitivelyDefault,
Expand Down Expand Up @@ -304,6 +311,7 @@ CompilerOptions parseOptions(List<String> 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'],
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 32e4f40

Please sign in to comment.