Skip to content

Commit

Permalink
Add an optional prefix for bundled js and css files.
Browse files Browse the repository at this point in the history
Set it with `WebAppInternals.setBundledJsCssPrefix(prefix)`.
  • Loading branch information
Emily Stark committed Dec 6, 2013
1 parent b5cd66d commit 6eccf8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/webapp/webapp_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var LONG_SOCKET_TIMEOUT = 120*1000;
WebApp = {};
WebAppInternals = {};

var bundledJsCssPrefix;

var makeAppNamePathPrefix = function (appName) {
return encodeURIComponent(appName).replace(/\./g, '_');
Expand Down Expand Up @@ -528,6 +529,11 @@ var runWebAppServer = function () {
/##ROOT_URL_PATH_PREFIX##/g,
__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.
var localPort = parseInt(process.env.PORT) || 0;
var host = process.env.BIND_IP;
Expand Down Expand Up @@ -707,3 +713,7 @@ WebAppInternals.inlineScriptsAllowed = function () {
WebAppInternals.setInlineScriptsAllowed = function (value) {
inlineScriptsAllowed = value;
};

WebAppInternals.setBundledJsCssPrefix = function (prefix) {
bundledJsCssPrefix = prefix;
};
4 changes: 2 additions & 2 deletions tools/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,13 +782,13 @@ _.extend(ClientTarget.prototype, {
'<html##HTML_ATTRIBUTES##>\n' +
'<head>\n');
_.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('">\n');
});
html.push('\n\n##RUNTIME_CONFIG##\n\n');
_.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('"></script>\n');
});
Expand Down

0 comments on commit 6eccf8c

Please sign in to comment.