Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify ha-style/Roboto and load asynchronously #18226

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cast/src/launcher/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "../../../src/resources/safari-14-attachshadow-patch";
import "../../../src/resources/ha-style";
import "../../../src/resources/roboto";
import "./layout/hc-connect";

import("../../../src/resources/ha-style");
4 changes: 2 additions & 2 deletions cast/src/receiver/second-load.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import "../../../src/resources/ha-style";
import "../../../src/resources/roboto";
import "./layout/hc-lovelace";

import("../../../src/resources/ha-style");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this entire module is already dynamically loaded

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just remove the import here? Was the static import a mistake?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean second-load.ts is already loaded dynamic, so we don't need to load ha-style dynamic too then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... yeah probably not, although it might end up creating 2 chunks. I'll check real quick.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took what I think is a better approach and just removed this module, and instead loaded both in hc-main. That way they are loaded in parallel and the bundle is slightly smaller.

4 changes: 2 additions & 2 deletions demo/src/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "../../src/resources/ha-style";
import "../../src/resources/roboto";
import "../../src/resources/safari-14-attachshadow-patch";
import "./ha-demo";

import("../../src/resources/ha-style");
4 changes: 2 additions & 2 deletions gallery/src/entrypoint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "../../src/resources/ha-style";
import "../../src/resources/roboto";
import "./ha-gallery";

import("../../src/resources/ha-style");

document.body.appendChild(document.createElement("ha-gallery"));
6 changes: 3 additions & 3 deletions hassio/src/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Compat needs to be first import
import "../../src/resources/compatibility";
import { setCancelSyntheticClickEvents } from "@polymer/polymer/lib/utils/settings";
import "../../src/resources/roboto";
import "../../src/resources/ha-style";
import "../../src/resources/safari-14-attachshadow-patch";
import "./hassio-main";

import("../../src/resources/ha-style");

setCancelSyntheticClickEvents(false);

const styleEl = document.createElement("style");
styleEl.innerHTML = `
styleEl.textContent = `
body {
font-family: Roboto, sans-serif;
-moz-osx-font-smoothing: grayscale;
Expand Down
4 changes: 2 additions & 2 deletions src/entrypoints/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
} from "@polymer/polymer/lib/utils/settings";
import "@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min";
import "../layouts/home-assistant";
import "../resources/ha-style";
import "../resources/roboto";

import("../resources/ha-style");

setPassiveTouchGestures(true);
setCancelSyntheticClickEvents(false);
4 changes: 2 additions & 2 deletions src/entrypoints/authorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import "../resources/compatibility";
import { setCancelSyntheticClickEvents } from "@polymer/polymer/lib/utils/settings";
import "../auth/ha-authorize";
import "../resources/ha-style";
import "../resources/roboto";
import "../resources/safari-14-attachshadow-patch";
import "../resources/array.flat.polyfill";

import("../resources/ha-style");

setCancelSyntheticClickEvents(false);
4 changes: 2 additions & 2 deletions src/entrypoints/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import "../resources/compatibility";
import { setCancelSyntheticClickEvents } from "@polymer/polymer/lib/utils/settings";
import "../onboarding/ha-onboarding";
import "../resources/ha-style";
import "../resources/roboto";
import "../resources/safari-14-attachshadow-patch";
import "../resources/array.flat.polyfill";

import("../resources/ha-style");

setCancelSyntheticClickEvents(false);

declare global {
Expand Down
2 changes: 1 addition & 1 deletion src/onboarding/particles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { tsParticles } from "tsparticles-engine";
import { loadLinksPreset } from "tsparticles-preset-links";
import { DEFAULT_PRIMARY_COLOR } from "../resources/ha-style";
import { DEFAULT_PRIMARY_COLOR } from "../resources/styles-data";

loadLinksPreset(tsParticles).then(() => {
tsParticles.load("particles", {
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/hardware/ha-config-hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { showOptionsFlowDialog } from "../../../dialogs/config-flow/show-dialog-
import { showRestartDialog } from "../../../dialogs/restart/show-dialog-restart";
import "../../../layouts/hass-subpage";
import { SubscribeMixin } from "../../../mixins/subscribe-mixin";
import { DEFAULT_PRIMARY_COLOR } from "../../../resources/ha-style";
import { DEFAULT_PRIMARY_COLOR } from "../../../resources/styles-data";
import { haStyle } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
import { hardwareBrandsUrl } from "../../../util/brands-url";
Expand Down
2 changes: 1 addition & 1 deletion src/panels/profile/ha-pick-theme-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "../../components/ha-textfield";
import {
DEFAULT_ACCENT_COLOR,
DEFAULT_PRIMARY_COLOR,
} from "../../resources/ha-style";
} from "../../resources/styles-data";
import { HomeAssistant } from "../../types";
import { documentationUrl } from "../../util/documentation-url";

Expand Down
Loading