Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: pkg/polymer/lib/src/build/build_filter.dart

Issue 61193002: Add a build filter (only necessary HTML files are emitted) and logic to use .min.js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/deploy.dart ('k') | pkg/polymer/lib/src/build/common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/build_filter.dart
diff --git a/pkg/polymer/lib/src/build/build_filter.dart b/pkg/polymer/lib/src/build/build_filter.dart
new file mode 100644
index 0000000000000000000000000000000000000000..61cdd076ae2bd19aa72ffccad23bad5a5d19fe8a
--- /dev/null
+++ b/pkg/polymer/lib/src/build/build_filter.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * Final phase of the polymer transformation: removes any files that are not
+ * needed for deployment.
+ */
+library polymer.src.build.build_filter;
+
+import 'dart:async';
+
+import 'package:barback/barback.dart';
+import 'common.dart';
+
+/**
+ * Removes any files not needed for deployment, such as internal build artifacts
+ * and non-entry HTML files.
+ */
+class BuildFilter extends Transformer with PolymerTransformer {
+ final TransformOptions options;
+ BuildFilter(this.options);
+
+ Future<bool> isPrimary(Asset input) => new Future.value(
+ // nothing is filtered in debug mode
+ options.releaseMode &&
+ // may filter non-entry HTML files and internal artifacts
+ (input.id.extension == '.html' || input.id.extension == '.scriptUrls') &&
+ // keep any entry points
+ !options.isHtmlEntryPoint(input.id));
+
+ Future apply(Transform transform) {
+ if (transform.primaryInput.id.extension == '.scriptUrls') {
+ return new Future.value(null);
+ }
+ return readPrimaryAsHtml(transform).then((document) {
+ // Keep .html files that don't use polymer, since the app developer might
+ // have non-polymer entrypoints.
+ if (document.queryAll('polymer-element').isEmpty) {
+ transform.addOutput(transform.primaryInput);
+ }
+ });
+ }
+}
« no previous file with comments | « pkg/polymer/lib/deploy.dart ('k') | pkg/polymer/lib/src/build/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698