OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** Transfomer used for pub-serve and pub-deploy. */ | 5 /** Transfomer used for pub-serve and pub-deploy. */ |
6 library polymer.transformer; | 6 library polymer.transformer; |
7 | 7 |
8 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
9 import 'package:observe/transform.dart'; | 9 import 'package:observe/transform.dart'; |
10 import 'src/build/code_extractor.dart'; | 10 import 'src/build/code_extractor.dart'; |
(...skipping 12 matching lines...) Expand all Loading... |
23 * | 23 * |
24 * At the end of these phases, this tranformer produces a single entrypoint HTML | 24 * At the end of these phases, this tranformer produces a single entrypoint HTML |
25 * file with a single Dart script that can later be compiled with dart2js. | 25 * file with a single Dart script that can later be compiled with dart2js. |
26 */ | 26 */ |
27 class PolymerTransformerGroup implements TransformerGroup { | 27 class PolymerTransformerGroup implements TransformerGroup { |
28 final Iterable<Iterable> phases; | 28 final Iterable<Iterable> phases; |
29 | 29 |
30 PolymerTransformerGroup(TransformOptions options) | 30 PolymerTransformerGroup(TransformOptions options) |
31 : phases = _createDeployPhases(options); | 31 : phases = _createDeployPhases(options); |
32 | 32 |
33 PolymerTransformerGroup.asPlugin(Map args) : this(_parseArgs(args)); | 33 PolymerTransformerGroup.asPlugin(BarbackSettings settings) |
| 34 : this(_parseSettings(settings)); |
34 } | 35 } |
35 | 36 |
36 | 37 TransformOptions _parseSettings(BarbackSettings settings) { |
37 TransformOptions _parseArgs(Map args) { | 38 var args = settings.transformer; |
38 return new TransformOptions( | 39 return new TransformOptions( |
39 entryPoints: _readEntrypoints(args['entry_points']), | 40 entryPoints: _readEntrypoints(args['entry_points']), |
40 directlyIncludeJS: args['js'] != false, // default to true | 41 directlyIncludeJS: args['js'] != false, // default to true |
41 contentSecurityPolicy: args['csp'] == true); // default to false | 42 contentSecurityPolicy: args['csp'] == true); // default to false |
42 } | 43 } |
43 | 44 |
44 _readEntrypoints(value) { | 45 _readEntrypoints(value) { |
45 if (value == null) return null; | 46 if (value == null) return null; |
46 var entryPoints = []; | 47 var entryPoints = []; |
47 bool error; | 48 bool error; |
(...skipping 14 matching lines...) Expand all Loading... |
62 | 63 |
63 List<List<Transformer>> _createDeployPhases(TransformOptions options) { | 64 List<List<Transformer>> _createDeployPhases(TransformOptions options) { |
64 return [ | 65 return [ |
65 [new InlineCodeExtractor(options)], | 66 [new InlineCodeExtractor(options)], |
66 [new ObservableTransformer()], | 67 [new ObservableTransformer()], |
67 [new ImportInliner(options)], | 68 [new ImportInliner(options)], |
68 [new ScriptCompactor(options)], | 69 [new ScriptCompactor(options)], |
69 [new PolyfillInjector(options)] | 70 [new PolyfillInjector(options)] |
70 ]; | 71 ]; |
71 } | 72 } |
OLD | NEW |