Skip to content

Commit c04c73b

Browse files
committed
fix: include path to inject css and js in production builds
They were only being included in the development server builds due to an oversight.
1 parent 53b45dd commit c04c73b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

dotnet/RAWebServer/src/modules/InterceptHtml.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,24 @@ public void ProcessRequest(HttpContext context) {
155155
// read file
156156
var html = File.ReadAllText(_fullPath, Encoding.UTF8);
157157

158+
// check for inject/index.css and inject/index.js
159+
var injectDir = context.Server.MapPath("~/App_Data/inject/");
160+
var cssPath = Path.Combine(injectDir, "index.css");
161+
var jsPath = Path.Combine(injectDir, "index.js");
162+
var injectBuilder = new StringBuilder();
163+
if (File.Exists(cssPath)) {
164+
injectBuilder.AppendLine("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + VirtualPathUtility.ToAbsolute("~/inject/index.css") + "\" />");
165+
}
166+
if (File.Exists(jsPath)) {
167+
injectBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + VirtualPathUtility.ToAbsolute("~/inject/index.js") + "\"></script>");
168+
}
169+
158170
// token replacement
159171
var machineDisplayName =
160172
new AliasResolver().Resolve(Environment.MachineName);
161173
html = html.Replace("%raweb.servername%", machineDisplayName);
162174
html = html.Replace("%raweb.basetag%", "<base href=\"" + VirtualPathUtility.ToAbsolute("~/") + "\" />");
163-
html = html.Replace("%raweb.overrides%", "");
175+
html = html.Replace("%raweb.overrides%", injectBuilder.ToString());
164176

165177
context.Response.ContentType = "text/html; charset=utf-8";
166178
context.Response.Write(html);

0 commit comments

Comments
 (0)