Skip to content

Commit

Permalink
fix(sass): not compiling for install server
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Nov 7, 2018
1 parent 5623bed commit e0f744d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
29 changes: 23 additions & 6 deletions src/sass/buildsass.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

var _ = require('lodash');
var path = require('path');
var sass = require('node-sass');
var nconf = require('nconf');
var settingUtil = require('../settings/settingsUtil');
Expand All @@ -22,7 +23,7 @@ var buildsass = {};
var sassOptionsDefaults = {
indentedSyntax: true,
includePaths: [
nconf.get('base_dir') + '/src/sass'
path.join(__dirname, '../../src/sass')
],
outputStyle: 'compressed'
};
Expand Down Expand Up @@ -56,6 +57,19 @@ function dynamicSass(entry, vars, success, error) {
});
}

function save(result) {
var fs = require('fs');
var themeCss = path.join(__dirname, '../../public/css/app.min.css');
fs.writeFileSync(themeCss, result);
}

buildsass.buildDefault = function(callback) {
dynamicSass('app.sass', {}, function(result) {
save(result);
return callback();
}, callback);
};

buildsass.build = function(callback) {
settingUtil.getSettings(function(err, s) {
if (!err && s) {
Expand All @@ -69,13 +83,16 @@ buildsass.build = function(callback) {
tertiary: settings.colorTertiary.value,
quaternary: settings.colorQuaternary.value
}, function(result) {
var fs = require('fs');
var themeCss = nconf.get('base_dir') + '/public/css/app.min.css';
fs.writeFileSync(themeCss, result);
save(result);
return callback();
}, callback);
} else {
// Build Defaults
dynamicSass('app.sass', {}, function(result) {
save(result);
return callback();
}, callback);
} else
return callback();
}
});
};

Expand Down
18 changes: 12 additions & 6 deletions src/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,19 @@ var async = require('async'),

require('socket.io')(server);

if (!server.listening) {
server.listen(port, '0.0.0.0', function() {
require('./sass/buildsass').buildDefault(function(err) {
if (err) {
winston.error(err);
return callback(err);
}

if (!server.listening) {
server.listen(port, '0.0.0.0', function() {
return callback();
});
} else
return callback();
});
} else
return callback();

});
};

})(WebServer);

0 comments on commit e0f744d

Please sign in to comment.