Add an optional prefix for bundled js and css files.

Set it with `WebAppInternals.setBundledJsCssPrefix(prefix)`.
This commit is contained in:
Emily Stark
2013-12-05 17:51:26 -08:00
parent b5cd66dedd
commit 6eccf8cbbb
2 changed files with 12 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ var LONG_SOCKET_TIMEOUT = 120*1000;
WebApp = {}; WebApp = {};
WebAppInternals = {}; WebAppInternals = {};
var bundledJsCssPrefix;
var makeAppNamePathPrefix = function (appName) { var makeAppNamePathPrefix = function (appName) {
return encodeURIComponent(appName).replace(/\./g, '_'); return encodeURIComponent(appName).replace(/\./g, '_');
@@ -528,6 +529,11 @@ var runWebAppServer = function () {
/##ROOT_URL_PATH_PREFIX##/g, /##ROOT_URL_PATH_PREFIX##/g,
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || ""); __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || "");
boilerplateHtml = boilerplateHtml.replace(
/##BUNDLED_JS_CSS_PREFIX##/g,
bundledJsCssPrefix ||
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || "");
// only start listening after all the startup code has run. // only start listening after all the startup code has run.
var localPort = parseInt(process.env.PORT) || 0; var localPort = parseInt(process.env.PORT) || 0;
var host = process.env.BIND_IP; var host = process.env.BIND_IP;
@@ -707,3 +713,7 @@ WebAppInternals.inlineScriptsAllowed = function () {
WebAppInternals.setInlineScriptsAllowed = function (value) { WebAppInternals.setInlineScriptsAllowed = function (value) {
inlineScriptsAllowed = value; inlineScriptsAllowed = value;
}; };
WebAppInternals.setBundledJsCssPrefix = function (prefix) {
bundledJsCssPrefix = prefix;
};

View File

@@ -782,13 +782,13 @@ _.extend(ClientTarget.prototype, {
'<html##HTML_ATTRIBUTES##>\n' + '<html##HTML_ATTRIBUTES##>\n' +
'<head>\n'); '<head>\n');
_.each(self.css, function (css) { _.each(self.css, function (css) {
html.push(' <link rel="stylesheet" href="##ROOT_URL_PATH_PREFIX##'); html.push(' <link rel="stylesheet" href="##BUNDLED_JS_CSS_PREFIX##');
html.push(_.escape(css.url)); html.push(_.escape(css.url));
html.push('">\n'); html.push('">\n');
}); });
html.push('\n\n##RUNTIME_CONFIG##\n\n'); html.push('\n\n##RUNTIME_CONFIG##\n\n');
_.each(self.js, function (js) { _.each(self.js, function (js) {
html.push(' <script type="text/javascript" src="##ROOT_URL_PATH_PREFIX##'); html.push(' <script type="text/javascript" src="##BUNDLED_JS_CSS_PREFIX##');
html.push(_.escape(js.url)); html.push(_.escape(js.url));
html.push('"></script>\n'); html.push('"></script>\n');
}); });