1
0
mirror of synced 2025-12-23 11:54:18 -05:00
Files
docs/javascripts
Kevin Heis d043e47b9e Merge pull request #7874 from danBamikiya/patch-1
fix: support the rewrite of browser rendered javascripts to typescripts. Resolves #7872
2021-07-14 13:18:58 -07:00
..
2021-06-22 17:30:40 +00:00

Javascripts

The code in this directory is destined to run in a web browser!

The index.ts file in this directory is bundled by Webpack. In development, we use webpack-dev-middleware to bundle automatically while running the server. In production, we run webpack --mode production via npm run build.

This file is then referenced in the footer:

<script src="/dist/index.js"></script>

Every other file in this directory is written as a module to be required in index.ts. They all have this format:

module.exports = () => {
  // Do some cool browser stuff
  // Note: by the time this runs, the DOM will be ready. :)
}

In development, the bundle will recompile every time a file used by javascripts/index.ts is changed. This ensures that you're always getting an up-to-date version of the script.

In production, the bundle is compiled during build-time.