Skip to content

Commit 6cf498b

Browse files
imlucaskangas
authored andcommitted
serve frontend via file:// instead of http://
- puts much less pressure on the renderer processes - think of this like making nginx serve your static content instead of the application
1 parent 9180aa2 commit 6cf498b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

main.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ var server = require('scout-server');
22
var debug = require('debug')('scout:main');
33

44
var STATIC = process.env.WATCH_DIRECTORY || __dirname;
5-
debug('pointing scout-server static serving at `%s`', STATIC);
6-
server.start({
7-
static: STATIC
8-
});
5+
server.start({});
96

107
if (process.env.WATCH_DIRECTORY) {
118
var watch = require('watch');
@@ -18,14 +15,14 @@ if (process.env.WATCH_DIRECTORY) {
1815

1916
var livereload = tinyLR();
2017
livereload.listen(opts.port, opts.host);
21-
console.log('Watching %s for changes', STATIC);
18+
debug('Watching %s for changes', STATIC);
2219
watch.watchTree(STATIC, {
2320
filter: function(filename) {
2421
return !NODE_MODULES_REGEX.test(filename);
2522
},
2623
ignoreDotFiles: true
2724
}, function(files) {
28-
console.log('File change detected! Sending reload message');
25+
debug('File change detected! Sending reload message');
2926
livereload.changed({
3027
body: {
3128
files: files

src/electron/window-manager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ var BrowserWindow = require('browser-window');
44
var app = require('app');
55
var debug = require('debug')('scout-electron:window-manager');
66
var attachMenu = require('./menu');
7+
var path = require('path');
78

8-
var DEFAULT_URL = 'http://localhost:29017/index.html#connect';
9+
var RESOURCES = path.resolve(__dirname, '../../');
10+
var DEFAULT_URL = 'file://' + path.join(RESOURCES, 'index.html#connect');
911

1012
var DEFAULT_WIDTH = 1024;
1113
var DEFAULT_HEIGHT = 700;
@@ -41,7 +43,7 @@ module.exports.create = function(opts) {
4143
debug('got new-window event!', event, url, frameName, disposition);
4244
event.preventDefault();
4345
module.exports.create({
44-
url: url
46+
url: 'file://' + RESOURCES + '/index.html' + url.replace('file://', '')
4547
});
4648
});
4749
return _window;

src/index.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ html(lang='en')
55
meta(http-equiv="Content-Security-Policy", content="default-src *; script-src 'self' http://localhost:35729; style-src 'self' 'unsafe-inline';")
66

77
meta(name='viewport', content='initial-scale=1')
8-
link(rel='stylesheet', href='index.css')
8+
link(rel='stylesheet', href='index.css', charset='UTF-8')
99
body
1010
#application
11-
script(src='index.js')
11+
script(src='index.js', charset='UTF-8')

0 commit comments

Comments
 (0)