Skip to content

Commit fc8eb83

Browse files
committed
fix: update build configuration and card registration
1 parent e3897c5 commit fc8eb83

File tree

6 files changed

+71
-61
lines changed

6 files changed

+71
-61
lines changed

dist/ha-mi-humidifier-card.js

Lines changed: 39 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ha-mi-humidifier-card.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hacs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "Mi Humidifier Card",
33
"render_readme": true,
4-
"filename": "ha-mi-humidifier-card.js",
5-
"content_in_root": true,
4+
"filename": "dist/ha-mi-humidifier-card.js",
5+
"content_in_root": false,
66
"homeassistant": "0.118.0",
77
"hacs": "1.6.0"
88
}

src/ha-mi-humidifier-card.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@ import { LitElement, html, css } from 'lit';
22
import { customElement, property } from 'lit/decorators.js';
33
import { HomeAssistant } from 'custom-card-helpers';
44

5+
// Register card in HACS
6+
if (!customElements.get('mi-humidifier-card')) {
7+
console.info(
8+
'%c MI-HUMIDIFIER-CARD %c Registering card... ',
9+
'color: white; background: #4527a0; font-weight: 700;',
10+
'color: #4527a0; background: white; font-weight: 700;',
11+
);
12+
13+
if (!window.customCards) {
14+
window.customCards = [];
15+
}
16+
17+
window.customCards.push({
18+
type: "custom:mi-humidifier-card",
19+
name: "Mi Humidifier Card",
20+
description: "A custom card for Mi Humidifier"
21+
});
22+
}
23+
524
declare global {
625
interface Window {
726
customCards: Array<{
@@ -12,35 +31,18 @@ declare global {
1231
}
1332
}
1433

15-
interface HumidifierCardConfig {
16-
type: 'custom:mi-humidifier-card';
17-
entity: string;
18-
show_image?: boolean;
19-
}
20-
21-
// Register card in HACS
22-
if (!window.customCards) {
23-
window.customCards = [];
24-
}
25-
26-
console.info(
27-
'%c MI-HUMIDIFIER-CARD %c Registering card... ',
28-
'color: white; background: #4527a0; font-weight: 700;',
29-
'color: #4527a0; background: white; font-weight: 700;',
30-
);
31-
32-
window.customCards.push({
33-
type: "custom:mi-humidifier-card",
34-
name: "Mi Humidifier Card",
35-
description: "A custom card for Mi Humidifier"
36-
});
37-
3834
console.info(
3935
'%c MI-HUMIDIFIER-CARD %c Version 1.0.0 ',
4036
'color: white; background: #4527a0; font-weight: 700;',
4137
'color: #4527a0; background: white; font-weight: 700;',
4238
);
4339

40+
interface HumidifierCardConfig {
41+
type: 'custom:mi-humidifier-card';
42+
entity: string;
43+
show_image?: boolean;
44+
}
45+
4446
@customElement('mi-humidifier-card')
4547
export class MiHumidifierCard extends LitElement {
4648
@property({ attribute: false }) public hass!: HomeAssistant;
@@ -330,7 +332,7 @@ export class MiHumidifierCard extends LitElement {
330332
height: 200px;
331333
margin: 0 auto 16px;
332334
display: block;
333-
background: url("/hacsfiles/ha-mi-humidifier-card/humidifier-1.png") no-repeat center;
335+
background: url("./humidifier-1.png") no-repeat center;
334336
background-size: contain;
335337
}
336338
.controls-row {

vite.config.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export default defineConfig({
1010
fileName: 'ha-mi-humidifier-card',
1111
formats: ['es']
1212
},
13-
outDir: '.',
14-
emptyOutDir: false,
13+
outDir: 'dist',
14+
emptyOutDir: true,
1515
sourcemap: true,
1616
target: 'es2015',
1717
rollupOptions: {
@@ -23,8 +23,7 @@ export default defineConfig({
2323
targets: [
2424
{
2525
src: 'images/humidifier-1.png',
26-
dest: '.',
27-
rename: 'humidifier-1.png'
26+
dest: 'dist'
2827
}
2928
]
3029
})

0 commit comments

Comments
 (0)