| 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 /** Common methods used by transfomers. */ | 5 /** Common methods used by transfomers. */ |
| 6 library polymer.src.build.common; | 6 library polymer.src.build.common; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 | 9 |
| 10 import 'package:barback/barback.dart'; | 10 import 'package:barback/barback.dart'; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 /** | 55 /** |
| 56 * True to include the compiled JavaScript directly from the HTML page. | 56 * True to include the compiled JavaScript directly from the HTML page. |
| 57 * If enabled this will remove "packages/browser/dart.js" and replace | 57 * If enabled this will remove "packages/browser/dart.js" and replace |
| 58 * `type="application/dart"` scripts with equivalent *.dart.js files. | 58 * `type="application/dart"` scripts with equivalent *.dart.js files. |
| 59 * | 59 * |
| 60 * If [contentSecurityPolicy] enabled, this will reference files | 60 * If [contentSecurityPolicy] enabled, this will reference files |
| 61 * named *.dart.precompiled.js. | 61 * named *.dart.precompiled.js. |
| 62 */ | 62 */ |
| 63 final bool directlyIncludeJS; | 63 final bool directlyIncludeJS; |
| 64 | 64 |
| 65 /** |
| 66 * Run transformers to create a releasable app. For example, include the |
| 67 * minified versions of the polyfills rather than the debug versions. |
| 68 */ |
| 69 final bool releaseMode; |
| 70 |
| 65 TransformOptions({entryPoints, this.contentSecurityPolicy: false, | 71 TransformOptions({entryPoints, this.contentSecurityPolicy: false, |
| 66 this.directlyIncludeJS: true}) | 72 this.directlyIncludeJS: true, this.releaseMode: true}) |
| 67 : entryPoints = entryPoints == null ? null | 73 : entryPoints = entryPoints == null ? null |
| 68 : entryPoints.map(_systemToAssetPath).toList(); | 74 : entryPoints.map(_systemToAssetPath).toList(); |
| 69 | 75 |
| 70 /** Whether an asset with [id] is an entry point HTML file. */ | 76 /** Whether an asset with [id] is an entry point HTML file. */ |
| 71 bool isHtmlEntryPoint(AssetId id) { | 77 bool isHtmlEntryPoint(AssetId id) { |
| 72 if (id.extension != '.html') return false; | 78 if (id.extension != '.html') return false; |
| 73 | 79 |
| 74 // Note: [id.path] is a relative path from the root of a package. | 80 // Note: [id.path] is a relative path from the root of a package. |
| 75 if (entryPoints == null) { | 81 if (entryPoints == null) { |
| 76 return id.path.startsWith('web/') || id.path.startsWith('test/'); | 82 return id.path.startsWith('web/') || id.path.startsWith('test/'); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return builder.relative(builder.join('/', id.path), | 184 return builder.relative(builder.join('/', id.path), |
| 179 from: builder.join('/', builder.dirname(sourceId.path))); | 185 from: builder.join('/', builder.dirname(sourceId.path))); |
| 180 } | 186 } |
| 181 | 187 |
| 182 | 188 |
| 183 /** Convert system paths to asset paths (asset paths are posix style). */ | 189 /** Convert system paths to asset paths (asset paths are posix style). */ |
| 184 String _systemToAssetPath(String assetPath) { | 190 String _systemToAssetPath(String assetPath) { |
| 185 if (path.Style.platform != path.Style.windows) return assetPath; | 191 if (path.Style.platform != path.Style.windows) return assetPath; |
| 186 return path.posix.joinAll(path.split(assetPath)); | 192 return path.posix.joinAll(path.split(assetPath)); |
| 187 } | 193 } |
| OLD | NEW |