I'm building Polymer.dart app that uses Django as a backend. And i want to keep all static files in "/static/" directory, or use cdn server for example. But "pub build" makes relative urls for scripts and other assets. Is there any way to inject absolute prefix for release in url during "pub build"?
UPD: So simplest solution was to make a transformer:
import 'dart:async';
import 'package:barback/barback.dart';
class UrlTransformer extends Transformer {
UrlTransformer.asPlugin();
String get allowedExtensions => '.html';
Future apply(Transform transform) {
return transform.primaryInput.readAsString().then((contents) {
transform.addOutput(new Asset.fromString(
transform.primaryInput.id,
contents.replaceAllMapped(
new RegExp(r'src="([^\{"]+)"'),
(Match m) => "src=\"/static/${m[1]}\"").replaceAll("href=\"", "href=\"/static/")
)
);
});
}
}
But i dont know how to put results of dart2js transformer to apropriate folder. Resulting JS files are in the same directory as *.html now.
I tried to put my transformer after $dart2js in pubspec but it throws errors when pub build at transformer initialisation step. So i can't make the transformer for that.
your_package/static,your_package/web/staticoryour_package/lib/static. You can have absolute URLs for assets inlib/...` you reference using thesrcattribute. Imports are handled a bit differently. - Günter Zöchbauersrc="http://eaxmple.com/static/js/my_app.dart.js"or relevant to the web root. - k-maks