frontend/build-scripts
Bram Kragten 1525ca1a29
Bump typescript, babel, webpack, eslint, polyfills
2022-10-05 16:03:49 +02:00
..
babel-plugins Inline mdi icons with babel plugin + bump build deps (#9498) 2021-07-12 09:26:07 -07:00
gulp Add auto completion for mdi icons to code editor (#13022) 2022-06-29 16:12:16 +00:00
rollup-plugins Bump @web/dev-server (#7792) 2020-11-24 12:04:22 +01:00
.eslintrc Gulpify build pipeline (#3145) 2019-05-02 11:35:46 -07:00
.eslintrc.json Gulpify build pipeline (#3145) 2019-05-02 11:35:46 -07:00
README.md Clarify title 2020-11-18 08:46:42 +00:00
bundle.js Bump typescript, babel, webpack, eslint, polyfills 2022-10-05 16:03:49 +02:00
env.js Fix version detection in build env to allow for nightly builds (#13062) 2022-07-02 00:22:54 +02:00
paths.js Reorganize gallery (#11116) 2022-01-06 20:20:57 -08:00
removedIcons.json Update Material Design Icons to v7.0.96 (#13175) 2022-07-21 11:43:48 +02:00
rollup.js Disable babel compact option (#9335) 2021-06-03 12:34:30 -07:00
util.js Silence babel warnings (#9158) 2021-05-10 22:57:42 +02:00
webpack.js Fix script/size_stats 2022-08-30 21:53:17 -04: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 but also have experimental Rollup support. 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.