mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Use hydrolysis for optimal panel built size
This commit is contained in:
parent
8c3f760683
commit
9239a56958
@ -40,6 +40,7 @@
|
|||||||
"eslint-plugin-html": "^1.5.1",
|
"eslint-plugin-html": "^1.5.1",
|
||||||
"eslint-plugin-import": "^1.11.0",
|
"eslint-plugin-import": "^1.11.0",
|
||||||
"html-minifier": "^3.0.1",
|
"html-minifier": "^3.0.1",
|
||||||
|
"hydrolysis": "^1.24.1",
|
||||||
"polymer-cli": "^0.12.0",
|
"polymer-cli": "^0.12.0",
|
||||||
"rollup": "^0.34.1",
|
"rollup": "^0.34.1",
|
||||||
"rollup-plugin-babel": "^2.6.1",
|
"rollup-plugin-babel": "^2.6.1",
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
var Vulcanize = require('vulcanize');
|
var Vulcanize = require('vulcanize');
|
||||||
var minify = require('html-minifier');
|
var minify = require('html-minifier');
|
||||||
|
var hyd = require('hydrolysis');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
if (!fs.existsSync('build')) {
|
if (!fs.existsSync('build')) {
|
||||||
@ -32,14 +33,12 @@ const baseVulcanOptions = {
|
|||||||
stripComments: true,
|
stripComments: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const vulcan = new Vulcanize({
|
const panelVulcan = new Vulcanize({
|
||||||
inlineScripts: true,
|
inlineScripts: true,
|
||||||
inlineCss: true,
|
inlineCss: true,
|
||||||
implicitStrip: true,
|
implicitStrip: true,
|
||||||
stripComments: true,
|
stripComments: true,
|
||||||
stripExcludes: [
|
stripExcludes: undefined,
|
||||||
'bower_components/polymer/polymer.html',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const toProcess = [
|
const toProcess = [
|
||||||
@ -58,13 +57,13 @@ 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: `panels/ha-panel-${panel}.html`,
|
||||||
|
vulcan: panelVulcan,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function process(entry) {
|
function process(entry) {
|
||||||
console.log('Processing', entry.source);
|
console.log('Processing', entry.source);
|
||||||
const vulc = entry.vulcan || vulcan;
|
entry.vulcan.process(entry.source, (err, inlinedHtml) => {
|
||||||
vulc.process(entry.source, (err, inlinedHtml) => {
|
|
||||||
if (err !== null) {
|
if (err !== null) {
|
||||||
console.error(entry.source, err);
|
console.error(entry.source, err);
|
||||||
return;
|
return;
|
||||||
@ -80,4 +79,11 @@ function process(entry) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
process(toProcess.pop());
|
// Fetch all dependencies of main app and exclude them from panels
|
||||||
|
hyd.Analyzer.analyze('src/home-assistant.html')
|
||||||
|
.then(function (analyzer) {
|
||||||
|
return analyzer._getDependencies('src/home-assistant.html');
|
||||||
|
})
|
||||||
|
.then(deps => { panelVulcan.stripExcludes = deps; })
|
||||||
|
// And then start vulcanizing!!
|
||||||
|
.then(() => process(toProcess.pop()));
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
<link rel='import' href='./layouts/login-form.html'>
|
<link rel='import' href='./layouts/login-form.html'>
|
||||||
<link rel='import' href='./layouts/home-assistant-main.html'>
|
<link rel='import' href='./layouts/home-assistant-main.html'>
|
||||||
<link rel='import' href='./resources/home-assistant-style.html'>
|
<link rel='import' href='./resources/home-assistant-style.html'>
|
||||||
<link rel='import' href='./resources/panel-imports.html'>
|
<!-- to support panels -->
|
||||||
|
<link rel="import" href="../layouts/partial-base.html">
|
||||||
|
|
||||||
<dom-module id='home-assistant'>
|
<dom-module id='home-assistant'>
|
||||||
<template>
|
<template>
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
<link rel='import' href='../../bower_components/paper-toolbar/paper-toolbar.html'>
|
<link rel='import' href='../../bower_components/paper-toolbar/paper-toolbar.html'>
|
||||||
<link rel='import' href='../../bower_components/paper-icon-button/paper-icon-button.html'>
|
<link rel='import' href='../../bower_components/paper-icon-button/paper-icon-button.html'>
|
||||||
|
|
||||||
|
<link rel='import' href='../components/ha-menu-button.html'>
|
||||||
|
|
||||||
<dom-module id='partial-base'>
|
<dom-module id='partial-base'>
|
||||||
<template>
|
<template>
|
||||||
<style is="custom-style" include="iron-positioning"></style>
|
<style is="custom-style" include="iron-positioning"></style>
|
||||||
@ -15,14 +17,14 @@
|
|||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-icon {
|
.title {
|
||||||
margin-right: 24px;
|
margin-left: 24px !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<paper-scroll-header-panel class='fit'>
|
<paper-scroll-header-panel class='fit'>
|
||||||
<paper-toolbar>
|
<paper-toolbar>
|
||||||
<paper-icon-button icon='mdi:menu' class$='[[computeMenuButtonClass(narrow, showMenu)]]' on-tap='toggleMenu'></paper-icon-button>
|
<ha-menu-button narrow='[[narrow]]' show-menu='[[showMenu]]'></ha-menu-button>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<content select='[header-title]'></content>
|
<content select='[header-title]'></content>
|
||||||
</div>
|
</div>
|
||||||
@ -49,13 +51,5 @@ Polymer({
|
|||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
computeMenuButtonClass: function (narrow, showMenu) {
|
|
||||||
return !narrow && showMenu ? 'menu-icon invisible' : 'menu-icon';
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleMenu: function () {
|
|
||||||
this.fire('open-menu');
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<!--
|
|
||||||
Components that are used by panels.
|
|
||||||
|
|
||||||
Temporary while we figure imports out.
|
|
||||||
-->
|
|
||||||
<link rel="import" href="../layouts/partial-base.html">
|
|
||||||
<link rel="import" href="../components/display-time.html">
|
|
||||||
<link rel="import" href="../components/domain-icon.html">
|
|
||||||
<link rel="import" href="../components/ha-menu-button.html">
|
|
||||||
<link rel="import" href="../../bower_components/paper-input/paper-textarea.html">
|
|
Loading…
x
Reference in New Issue
Block a user