51e6f33d32
Don't precompile Dart2JS for pull requests, instead serve the dart sources with pub serve. We were already testing with Dartium so all we lose is some test coverage of defects exposed only by the Dart2JS transpiler. This still runs the dart transformer. Fixes #3030
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
var onHeaders = require('on-headers');
|
|
var proxy = require('proxy-middleware');
|
|
var url = require('url');
|
|
|
|
module.exports = function(gulp, plugins, config) {
|
|
return function() {
|
|
plugins.connect.server({
|
|
root: [__dirname + '/../../' + config.path],
|
|
port: config.port,
|
|
livereload: false,
|
|
open: false,
|
|
middleware: function(connect, opt) {
|
|
config.proxies = config.proxies || [];
|
|
var middlewares =
|
|
config.proxies.map(function(entry) { return makeProxy(entry.route, entry.url); });
|
|
middlewares.push(connect.favicon());
|
|
// pub serve can't give the right content-type header for jsonp requests
|
|
// so we must turn off Chromium strict MIME type checking
|
|
// see https://github.com/angular/angular/issues/3030#issuecomment-123453168
|
|
middlewares.unshift(stripHeader('x-content-type-options'));
|
|
return middlewares;
|
|
}
|
|
})();
|
|
};
|
|
};
|
|
|
|
function makeProxy(route, urlParam) {
|
|
var options = url.parse(urlParam);
|
|
options.route = route;
|
|
return proxy(options);
|
|
}
|
|
|
|
function stripHeader(toStrip) {
|
|
return function(req, res, next) {
|
|
onHeaders(res, function onHeaders() {
|
|
res.removeHeader(toStrip);
|
|
});
|
|
next();
|
|
};
|
|
}
|