fix(css): when compiling CSS, leave absolute imports alone
Closes #4592
This commit is contained in:
@ -59,9 +59,8 @@ Uri toAssetScheme(Uri absoluteUri) {
|
||||
return absoluteUri;
|
||||
}
|
||||
if (absoluteUri.scheme != 'package') {
|
||||
throw new FormatException(
|
||||
'Unsupported URI scheme "${absoluteUri.scheme}" encountered.',
|
||||
absoluteUri);
|
||||
// Pass through URIs with non-package scheme
|
||||
return absoluteUri;
|
||||
}
|
||||
|
||||
if (absoluteUri.pathSegments.length < 2) {
|
||||
|
@ -88,9 +88,9 @@ void allTests() {
|
||||
.toThrowWith(anInstanceOf: FormatException);
|
||||
});
|
||||
|
||||
it('should throw for unsupported schemes', () {
|
||||
expect(() => toAssetScheme(Uri.parse('file:///angular2')))
|
||||
.toThrowWith(anInstanceOf: FormatException);
|
||||
it('should pass through unsupported schemes', () {
|
||||
var uri = 'http://server.com/style.css';
|
||||
expect('${toAssetScheme(Uri.parse(uri))}').toEqual(uri);
|
||||
});
|
||||
|
||||
it('should throw if passed a null uri', () {
|
||||
|
@ -16,6 +16,9 @@ const SIMPLE_CSS = '''
|
||||
}
|
||||
''';
|
||||
|
||||
const HTTP_IMPORT = 'https://fonts.googleapis.com/css?family=Roboto';
|
||||
const CSS_WITH_IMPORT = '@import url(${HTTP_IMPORT});';
|
||||
|
||||
main() {
|
||||
Html5LibDomAdapter.makeCurrent();
|
||||
allTests();
|
||||
@ -60,6 +63,20 @@ allTests() {
|
||||
expect(transform.outputs[1].id.toString())
|
||||
.toEqual('somepackage|lib/style.css.shim.dart');
|
||||
});
|
||||
|
||||
it('should compile stylesheets with imports', () async {
|
||||
var cssFile = new Asset.fromString(
|
||||
new AssetId('somepackage', 'lib/style.css'), CSS_WITH_IMPORT);
|
||||
var transform = new FakeTransform()..primaryInput = cssFile;
|
||||
await subject.apply(transform);
|
||||
expect(transform.outputs.length).toBe(2);
|
||||
expect(transform.outputs[0].id.toString())
|
||||
.toEqual('somepackage|lib/style.css.dart');
|
||||
expect(transform.outputs[1].id.toString())
|
||||
.toEqual('somepackage|lib/style.css.shim.dart');
|
||||
expect(await transform.outputs[0].readAsString()).toContain(HTTP_IMPORT);
|
||||
expect(await transform.outputs[1].readAsString()).toContain(HTTP_IMPORT);
|
||||
});
|
||||
}
|
||||
|
||||
@proxy
|
||||
|
Reference in New Issue
Block a user