diff --git a/.gitignore b/.gitignore index a6fef79fcb..827cd0b2d7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ build/ dist/ /hass_frontend/ +/logs/dist/ /translations/ # yarn diff --git a/build-scripts/bundle.cjs b/build-scripts/bundle.cjs index 98fb78ce13..9c047dd141 100644 --- a/build-scripts/bundle.cjs +++ b/build-scripts/bundle.cjs @@ -327,6 +327,20 @@ module.exports.config = { }; }, + logs({ isProdBuild, latestBuild, isStatsBuild }) { + return { + name: "logs" + nameSuffix(latestBuild), + entry: { + entrypoint: path.resolve(paths.logs_dir, "src/entrypoint.ts"), + }, + outputPath: outputPath(paths.logs_output_root, latestBuild), + publicPath: publicPath(latestBuild), + isProdBuild, + latestBuild, + isStatsBuild, + }; + }, + landingPage({ isProdBuild, latestBuild }) { return { name: "landing-page" + nameSuffix(latestBuild), diff --git a/build-scripts/gulp/clean.js b/build-scripts/gulp/clean.js index b7c570c9d4..3b28ea115b 100644 --- a/build-scripts/gulp/clean.js +++ b/build-scripts/gulp/clean.js @@ -39,6 +39,13 @@ gulp.task( ) ); +gulp.task( + "clean-logs", + gulp.parallel("clean-translations", async () => + deleteSync([paths.logs_output_root, paths.build_dir]) + ) +); + gulp.task( "clean-landing-page", gulp.parallel("clean-translations", async () => diff --git a/build-scripts/gulp/entry-html.js b/build-scripts/gulp/entry-html.js index d41dd8f457..d11c10e34b 100644 --- a/build-scripts/gulp/entry-html.js +++ b/build-scripts/gulp/entry-html.js @@ -245,6 +245,24 @@ gulp.task( ) ); +const LOGS_PAGE_ENTRIES = { "index.html": ["entrypoint"] }; + +gulp.task( + "gen-pages-logs-dev", + genPagesDevTask(LOGS_PAGE_ENTRIES, paths.logs_dir, paths.logs_output_root) +); + +gulp.task( + "gen-pages-logs-prod", + genPagesProdTask( + LOGS_PAGE_ENTRIES, + paths.logs_dir, + paths.logs_output_root, + paths.logs_output_latest, + paths.logs_output_es5 + ) +); + const LANDING_PAGE_PAGE_ENTRIES = { "index.html": ["entrypoint"] }; gulp.task( diff --git a/build-scripts/gulp/gather-static.js b/build-scripts/gulp/gather-static.js index 0c8637c21c..638767dfab 100644 --- a/build-scripts/gulp/gather-static.js +++ b/build-scripts/gulp/gather-static.js @@ -202,6 +202,16 @@ gulp.task("copy-static-gallery", async () => { copyMdiIcons(paths.gallery_output_static); }); +gulp.task("copy-static-logs", async () => { + // Copy app static files + fs.copySync(polyPath("public/static"), paths.logs_output_static); + + copyFonts(paths.logs_output_static); + copyTranslations(paths.logs_output_static); + copyLocaleData(paths.logs_output_static); + copyMdiIcons(paths.logs_output_static); +}); + gulp.task("copy-static-landing-page", async () => { // Copy landing-page static files fs.copySync( diff --git a/build-scripts/gulp/index.mjs b/build-scripts/gulp/index.mjs index 8ae6311ff2..7f1938ca89 100644 --- a/build-scripts/gulp/index.mjs +++ b/build-scripts/gulp/index.mjs @@ -7,6 +7,7 @@ import "./download-translations.js"; import "./entry-html.js"; import "./fetch-nightly-translations.js"; import "./gallery.js"; +import "./logs.js"; import "./gather-static.js"; import "./gen-icons-json.js"; import "./hassio.js"; diff --git a/build-scripts/gulp/logs.js b/build-scripts/gulp/logs.js new file mode 100644 index 0000000000..478de1f761 --- /dev/null +++ b/build-scripts/gulp/logs.js @@ -0,0 +1,39 @@ +import gulp from "gulp"; +import "./clean.js"; +import "./entry-html.js"; +import "./gather-static.js"; +import "./gen-icons-json.js"; +import "./translations.js"; +import "./rspack.js"; + +gulp.task( + "develop-logs", + gulp.series( + async function setEnv() { + process.env.NODE_ENV = "development"; + }, + "clean-logs", + gulp.parallel( + "gen-icons-json", + "gen-pages-logs-dev", + "build-translations", + "build-locale-data" + ), + "copy-static-logs", + "rspack-dev-server-logs" + ) +); + +gulp.task( + "build-logs", + gulp.series( + async function setEnv() { + process.env.NODE_ENV = "production"; + }, + "clean-logs", + gulp.parallel("gen-icons-json", "build-translations", "build-locale-data"), + "copy-static-logs", + "rspack-prod-logs", + "gen-pages-logs-prod" + ) +); diff --git a/build-scripts/gulp/rspack.js b/build-scripts/gulp/rspack.js index 84f9d71079..7498a3bcbf 100644 --- a/build-scripts/gulp/rspack.js +++ b/build-scripts/gulp/rspack.js @@ -15,6 +15,7 @@ import { createGalleryConfig, createHassioConfig, createLandingPageConfig, + createLogsConfig, } from "../rspack.cjs"; const bothBuilds = (createConfigFunc, params) => [ @@ -204,6 +205,25 @@ gulp.task("rspack-prod-gallery", () => ) ); +gulp.task("rspack-dev-server-logs", () => + runDevServer({ + compiler: rspack( + createLogsConfig({ isProdBuild: false, latestBuild: true }) + ), + contentBase: paths.logs_output_root, + port: 5647, + }) +); + +gulp.task("rspack-prod-logs", () => + prodBuild( + bothBuilds(createLogsConfig, { + isProdBuild: true, + isStatsBuild: env.isStatsBuild(), + }) + ) +); + gulp.task("rspack-watch-landing-page", () => { // This command will run forever because we don't close compiler rspack( diff --git a/build-scripts/paths.cjs b/build-scripts/paths.cjs index b181ee7c00..3ebb5b0f07 100644 --- a/build-scripts/paths.cjs +++ b/build-scripts/paths.cjs @@ -59,5 +59,11 @@ module.exports = { hassio_output_es5: path.resolve(__dirname, "../hassio/build/frontend_es5"), hassio_publicPath: "/api/hassio/app", + logs_dir: path.resolve(__dirname, "../logs"), + logs_output_root: path.resolve(__dirname, "../logs/dist"), + logs_output_static: path.resolve(__dirname, "../logs/dist/static"), + logs_output_latest: path.resolve(__dirname, "../logs/dist/frontend_latest"), + logs_output_es5: path.resolve(__dirname, "../logs/dist/frontend_es5"), + translations_src: path.resolve(__dirname, "../src/translations"), }; diff --git a/build-scripts/rspack.cjs b/build-scripts/rspack.cjs index 76f85214f6..d02a3f10b3 100644 --- a/build-scripts/rspack.cjs +++ b/build-scripts/rspack.cjs @@ -302,6 +302,11 @@ const createHassioConfig = ({ const createGalleryConfig = ({ isProdBuild, latestBuild }) => createRspackConfig(bundle.config.gallery({ isProdBuild, latestBuild })); +const createLogsConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => + createRspackConfig( + bundle.config.logs({ isProdBuild, latestBuild, isStatsBuild }) + ); + const createLandingPageConfig = ({ isProdBuild, latestBuild }) => createRspackConfig(bundle.config.landingPage({ isProdBuild, latestBuild })); @@ -311,6 +316,7 @@ module.exports = { createCastConfig, createHassioConfig, createGalleryConfig, + createLogsConfig, createRspackConfig, createLandingPageConfig, }; diff --git a/logs/src/entrypoint.ts b/logs/src/entrypoint.ts new file mode 100644 index 0000000000..80ace73593 --- /dev/null +++ b/logs/src/entrypoint.ts @@ -0,0 +1,5 @@ +import "./logs-app"; + +import("../../src/resources/append-ha-style"); + +document.body.appendChild(document.createElement("logs-app")); diff --git a/logs/src/html/index.html.template b/logs/src/html/index.html.template new file mode 100644 index 0000000000..0f26862fc6 --- /dev/null +++ b/logs/src/html/index.html.template @@ -0,0 +1,36 @@ + + +
+ + + +This is a minimal logs frontend application.
+