|
|
@@ -1,5 +1,9 @@ |
|
|
|
|
|
|
|
const { ipcRenderer } = require('electron') |
|
|
|
const sass = require('sass'); |
|
|
|
const path = require('path'); |
|
|
|
const fs = require('fs'); |
|
|
|
|
|
|
|
const SASS_BASE_PATH = 'view/sass'; |
|
|
|
|
|
|
|
// TODO: Once configs are setup, make this section more dynamic!! |
|
|
|
var VARS = { |
|
|
@@ -12,6 +16,20 @@ var VARS = { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
console.log(ipcRenderer.sendSync("getPath", "app")); |
|
|
|
function handleFileLoad(url, prev, done){ |
|
|
|
let apppath = ipcRenderer.sendSync("getPath", "app"); |
|
|
|
let filepath = path.join(apppath, SASS_BASE_PATH, url + ".scss"); |
|
|
|
console.log("Attempting to load ", filepath); |
|
|
|
fs.readFile(filepath, 'utf-8', (err, data) => { |
|
|
|
if (err){ |
|
|
|
done(err); |
|
|
|
} else { |
|
|
|
done({contents: data.toString()}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function buildSASSVars(){ |
|
|
|
let res = ""; |
|
|
|
Object.keys(VARS).forEach((key)=>{ |
|
|
@@ -23,7 +41,7 @@ function buildSASSVars(){ |
|
|
|
function render(entryfile){ |
|
|
|
return new Promise((res, rej) => { |
|
|
|
let entry = buildSASSVars() + "@import '" + entryfile + "';\n"; |
|
|
|
sass.render({data: entry, includePaths:['view/sass/']}, (err, data) => { |
|
|
|
sass.render({data: entry, importer:handleFileLoad}, (err, data) => { |
|
|
|
if (err){rej(err);} |
|
|
|
res(data); |
|
|
|
}); |