mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 18:06:36 +00:00
Tweak vulcanize script
This commit is contained in:
parent
de754bb903
commit
fe6fa5cab6
@ -43,8 +43,8 @@ const panelVulcan = new Vulcanize({
|
|||||||
|
|
||||||
const toProcess = [
|
const toProcess = [
|
||||||
{
|
{
|
||||||
source: 'src/home-assistant.html',
|
source: './src/home-assistant.html',
|
||||||
output: 'frontend.html',
|
output: './build/frontend.html',
|
||||||
vulcan: new Vulcanize(Object.assign({}, baseVulcanOptions, {
|
vulcan: new Vulcanize(Object.assign({}, baseVulcanOptions, {
|
||||||
stripExcludes: [
|
stripExcludes: [
|
||||||
'bower_components/font-roboto/roboto.html',
|
'bower_components/font-roboto/roboto.html',
|
||||||
@ -55,27 +55,25 @@ const toProcess = [
|
|||||||
|
|
||||||
fs.readdirSync('./panels').forEach(panel => {
|
fs.readdirSync('./panels').forEach(panel => {
|
||||||
toProcess.push({
|
toProcess.push({
|
||||||
source: `panels/${panel}/ha-panel-${panel}.html`,
|
source: `./panels/${panel}/ha-panel-${panel}.html`,
|
||||||
output: `panels/ha-panel-${panel}.html`,
|
output: `./build/panels/ha-panel-${panel}.html`,
|
||||||
vulcan: panelVulcan,
|
vulcan: panelVulcan,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function process(entry) {
|
function vulcanizeEntry(entry) {
|
||||||
console.log('Processing', entry.source);
|
return new Promise((resolve, reject) => {
|
||||||
entry.vulcan.process(entry.source, (err, inlinedHtml) => {
|
console.log('Processing', entry.source);
|
||||||
if (err !== null) {
|
entry.vulcan.process(entry.source, (err, inlinedHtml) => {
|
||||||
console.error(entry.source, err);
|
if (err !== null) {
|
||||||
return;
|
reject(`${entry.source}: ${err}`);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const out = 'build/' + entry.output;
|
console.log('Writing', entry.output);
|
||||||
console.log('Writing', out);
|
fs.writeFileSync(entry.output, minifyHTML(inlinedHtml));
|
||||||
fs.writeFileSync(out, minifyHTML(inlinedHtml));
|
resolve();
|
||||||
|
});
|
||||||
if (toProcess.length) {
|
|
||||||
process(toProcess.pop());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,5 +83,7 @@ hyd.Analyzer.analyze('src/home-assistant.html')
|
|||||||
return analyzer._getDependencies('src/home-assistant.html');
|
return analyzer._getDependencies('src/home-assistant.html');
|
||||||
})
|
})
|
||||||
.then(deps => { panelVulcan.stripExcludes = deps; })
|
.then(deps => { panelVulcan.stripExcludes = deps; })
|
||||||
// And then start vulcanizing!!
|
// Chain all vulcanizing work as promises
|
||||||
.then(() => process(toProcess.pop()));
|
.then(() => toProcess.reduce(
|
||||||
|
(p, entry) => p.then(() => vulcanizeEntry(entry)),
|
||||||
|
Promise.resolve()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user