Permalink
Browse files

feature: MDLCleanupTransformer reduces package size by around 50%

  • Loading branch information...
MikeMitterer committed Nov 2, 2015
1 parent 6cabb87 commit eabab78115e620b0e41f316539bbe71cdec9b206
Showing with 179 additions and 5 deletions.
  1. +2 −5 lib/mdl.dart
  2. +48 −0 lib/transformer.dart
  3. +3 −0 samples/mdl_animation/pubspec.yaml
  4. +3 −0 samples/mdl_badge/pubspec.yaml
  5. +3 −0 samples/mdl_button/pubspec.yaml
  6. +3 −0 samples/mdl_card/pubspec.yaml
  7. +3 −0 samples/mdl_checkbox/pubspec.yaml
  8. +3 −0 samples/mdl_data-table/pubspec.yaml
  9. +3 −0 samples/mdl_footer/pubspec.yaml
  10. +3 −0 samples/mdl_grid/pubspec.yaml
  11. +3 −0 samples/mdl_icon-toggle/pubspec.yaml
  12. +3 −0 samples/mdl_layout/pubspec.yaml
  13. +3 −0 samples/mdl_menu/pubspec.yaml
  14. +3 −0 samples/mdl_palette/pubspec.yaml
  15. +3 −0 samples/mdl_progress/pubspec.yaml
  16. +3 −0 samples/mdl_radio/pubspec.yaml
  17. +3 −0 samples/mdl_shadow/pubspec.yaml
  18. +3 −0 samples/mdl_slider/pubspec.yaml
  19. +3 −0 samples/mdl_spinner/pubspec.yaml
  20. +3 −0 samples/mdl_switch/pubspec.yaml
  21. +3 −0 samples/mdl_tabs/pubspec.yaml
  22. +3 −0 samples/mdl_textfield/pubspec.yaml
  23. +3 −0 samples/mdl_tooltip/pubspec.yaml
  24. +3 −0 samples/mdl_typography/pubspec.yaml
  25. +3 −0 samples/mdld_attribute/pubspec.yaml
  26. +3 −0 samples/mdld_class/pubspec.yaml
  27. +3 −0 samples/mdld_formatter/pubspec.yaml
  28. +3 −0 samples/mdld_model/pubspec.yaml
  29. +3 −0 samples/mdld_observe/pubspec.yaml
  30. +3 −0 samples/mdld_repeat/pubspec.yaml
  31. +3 −0 samples/mdld_repeat_data-table/pubspec.yaml
  32. +3 −0 samples/mdlo_icons/pubspec.yaml
  33. +3 −0 samples/mdlo_list/pubspec.yaml
  34. +3 −0 samples/mdlx_accordion/pubspec.yaml
  35. +3 −0 samples/mdlx_data-table2/pubspec.yaml
  36. +3 −0 samples/mdlx_dialog/pubspec.yaml
  37. +3 −0 samples/mdlx_dnd/pubspec.yaml
  38. +3 −0 samples/mdlx_forms/pubspec.yaml
  39. +3 −0 samples/mdlx_nav-pills/pubspec.yaml
  40. +3 −0 samples/mdlx_notification/pubspec.yaml
  41. +3 −0 samples/mdlx_panel/pubspec.yaml
  42. +3 −0 samples/mdlx_snackbar/pubspec.yaml
  43. +3 −0 samples/spa_content/pubspec.yaml
  44. +3 −0 samples/spa_todo/pubspec.yaml
  45. +3 −0 tool/templates/pubspec.tmpl.yaml
View
@@ -8,6 +8,8 @@ import "package:mdl/mdlformatter.dart";
import "package:mdl/mdldialog.dart";
import "package:mdl/mdlform.dart";
export "package:mdl/mdlcore.dart";
export "package:mdl/mdlcomponets.dart";
export "package:mdl/mdldirective.dart";
@@ -19,11 +21,6 @@ export "package:mdl/mdlobservable.dart";
export "package:mdl/mdlformatter.dart";
export "package:mdl/mdldnd.dart";
import 'package:barback/barback.dart';
import 'dart:async';
part "src/transformer/transformer.dart";
void registerMdl() {
registerMdlTemplateComponents();
View
@@ -0,0 +1,48 @@
library mdl.transformer;
import 'dart:async';
import 'package:path/path.dart' as path;
import 'package:barback/barback.dart';
/**
* This transformer removes unnecessary "style-files and style-folders" like
* lib/assets/themes. It also removes lib/_templates
*
* For the "styleguide-sample" this reduces the package size by around 50%!
*/
class MDLCleanupTransformer extends Transformer implements LazyTransformer {
final BarbackSettings _settings;
// A constructor named "asPlugin" is required. It can be empty, but
// it must be present. It is how pub determines that you want this
// class to be publicly available as a loadable transformer plugin.
MDLCleanupTransformer.asPlugin(this._settings);
Future<bool> isPrimary(final AssetId id) async {
//print("Path: ${id.path}");
if(id.path.startsWith("lib${path.separator}_templates${path.separator}")) {
return true;
} else if(id.path.startsWith("lib${path.separator}assets${path.separator}themes${path.separator}")) {
return true;
} else if(id.path.startsWith("lib${path.separator}assets${path.separator}")) {
final String file = path.basename(id.path);
final String extension = path.extension(id.path).toLowerCase();
return (extension == ".scss" || extension == ".md" || extension == ".html" || extension == ".txt");
}
return false;
}
Future apply(final Transform transform) async {
// print("Apply-Path: ${transform.primaryInput.id.path}");
// Skip the transform in debug mode. (pub serve / pub build --mode=<mode>)
// if (_settings.mode.name == 'debug') return;
//final AssetId id = transform.primaryInput.id;
return transform.consumePrimary();
}
@override
void declareOutputs(final DeclaringTransform transform) { }
}
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
@@ -22,8 +22,11 @@ dependencies:
di: ^3.3.0
dart_to_js_script_rewriter: ^0.1.0
transformers:
- di
- dart_to_js_script_rewriter
# - $dart2js:
# commandLineOptions: [--enable-experimental-mirrors]
Oops, something went wrong.

0 comments on commit eabab78

Please sign in to comment.