frontend/build-scripts
Steve Repsher 2fe6203eae
Remove leftover packages from Rollup builds (#23344)
2024-12-19 15:16:08 -05:00
..
babel-plugins Remove unused polyfills and adjust support for Intl.getCanonicalLocales (#23264) 2024-12-12 15:07:50 +02:00
gulp Remove leftover packages from Rollup builds (#23344) 2024-12-19 15:16:08 -05:00
README.md Remove rollup build configuration (#22181) 2024-11-08 10:19:52 +02:00
bundle.cjs Made it easier to test the frontend against an existing core instance. (#23062) 2024-12-02 13:27:36 +00:00
env.cjs Cleanup unused WDS deps and config (#23155) 2024-12-06 09:57:46 +01:00
eslint.config.mjs ESLint Flat Config (#22221) 2024-11-18 15:49:59 +01:00
list-plugins-and-polyfills.js Enable shipped proposals in Babel (#17909) 2023-09-19 13:56:55 +02:00
paths.cjs Landing page (#22598) 2024-11-20 16:20:08 +00:00
removedIcons.json Remove deprecated and removed icons (#15762) 2023-03-08 12:28:34 +01:00
rspack.cjs Rspack (#22807) 2024-11-26 14:49:13 +01:00

README.md

Bundling Home Assistant Frontend

The Home Assistant build pipeline contains various steps to prepare a build.

  • Generating icon files to be included
  • Generating translation files to be included
  • Converting TypeScript, CSS and JSON files to JavaScript
  • Bundling
  • Minifying the files
  • Generating the HTML entrypoint files
  • Generating the service worker
  • Compressing the files

Converting files

Currently in Home Assistant we use a bundler to convert TypeScript, CSS and JSON files to JavaScript files that the browser understands.

We currently rely on Webpack. Both of these programs bundle the converted files in both production and development.

For development, bundling is optional. We just want to get the right files in the browser.

Responsibilities of the converter during development:

  • Convert TypeScript to JavaScript
  • Convert CSS to JavaScript that sets the content as the default export
  • Convert JSON to JavaScript that sets the content as the default export
  • Make sure import, dynamic import and web worker references work
    • Add extensions where missing
    • Resolve absolute package imports
  • Filter out specific imports/packages
  • Replace constants with values

In production, the following responsibilities are added:

  • Minify HTML
  • Bundle multiple imports so that the browser can fetch less files
  • Generate a second version that is ES5 compatible

Configuration for all these steps are specified in bundle.js.