OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 library polymer_interop.src.build.replace_polymer_js.dart; | |
5 | |
6 import 'dart:async'; | |
7 import 'package:barback/barback.dart'; | |
8 | |
9 /// Replaces `polymer.min.js` with `polymer.js` in development mode. | |
10 class ReplacePolymerJsTransformer extends Transformer { | |
11 BarbackSettings settings; | |
12 | |
13 ReplacePolymerJsTransformer.asPlugin(this.settings); | |
14 | |
15 bool isPrimary(AssetId id) { | |
16 if (settings.mode == BarbackMode.RELEASE) return false; | |
17 return id.path == 'lib/src/js/polymer.html'; | |
18 } | |
19 | |
20 Future apply(Transform transform) async { | |
21 var contents = await transform.primaryInput.readAsString(); | |
22 contents = contents.replaceFirst('polymer.min.js', 'polymer.js'); | |
23 transform | |
24 .addOutput(new Asset.fromString(transform.primaryInput.id, contents)); | |
25 } | |
26 } | |
OLD | NEW |