Repository navigation
Commit 87fadd2
committed
[gui] Speed up the web UI build
A clean build of the web UI (`npm run build`, also run by `make package`)
took about 76 seconds. It now takes about 6 seconds.
Root causes
-----------
1. The whole Vuetify stylesheet was compiled again for every component.
`src/variables.scss` started with `@use 'vuetify/styles'`. Webpack adds
this file to the top of every SCSS/Sass `<style>` block, so the full
Vuetify CSS (about 350 KB) was compiled and bundled once per component,
about 56 times. This was most of the build time. It also made the output
twice as big (32 MB instead of 15 MB) and `main.js` 7 MB instead of 1 MB.
`main.js` already imports `vuetify/styles` once, so these copies were not
needed.
2. The JavaScript minifier was slow. Webpack uses Terser by default, which
runs in JavaScript and makes two passes over the code.
3. Babel did more work than needed. Without a browser target it converted
all code down to old ES5 syntax, and it also processed the whole Vuetify
library from node_modules.
4. ESLint ran inside every production build, even though CI already runs
`npm run test:lint` separately.
Fixes
-----
- `variables.scss` now only contains Sass variables, so it no longer outputs
any CSS. The `:root` color variables moved to a new `src/global.css` file,
imported once from `main.js`. A comment in `variables.scss` explains why
CSS must not be put there.
- Minify with esbuild (through `minimizer-webpack-plugin`, which webpack
already uses) instead of Terser.
- Add a "browserslist" target ("defaults") to package.json, and stop running
Babel on packages in node_modules.
- Run the ESLint webpack plugin only in the development config.
- Let webpack clean the `dist` folder (`output.clean`) instead of running
`rimraf` before the build.
- Clear the webpack cache when any build config file, package.json or
.babelrc changes, not only when `webpack.common.js` changes.
- Makefile: do not run `npm install` twice when the UI has to be rebuilt.
- Remove `vue.config.js`, a leftover from Vue CLI that nothing reads.
- Fix `v-model` on a constant in `RunList.vue` and
`ListReviewStatusRules.vue` (`itemsPerPageOptions`). esbuild warned that
this assignment would throw. It is now a one-way `:items-per-page-options`
binding.
Results
-------
Clean build with an empty cache, measured on the same machine.
| | Before | After |
| ----------------------- | ------ | ------ |
| `npm run build` (total) | 76 s | 6 s |
| webpack compile time | 72 s | 4.3 s |
| `dist` size | 32 MB | 15 MB |
This PR was mainly generated by AI.1 parent 451b0c5 commit 87fadd2
12 files changed
Lines changed: 572 additions & 51 deletions
File tree
- web
- server/vue-cli
- config
- src
- components/ReviewStatus
- views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
94 | 93 | | |
95 | 94 | | |
96 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
101 | | - | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
203 | 205 | | |
204 | 206 | | |
205 | 207 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | 208 | | |
211 | 209 | | |
212 | 210 | | |
| |||
244 | 242 | | |
245 | 243 | | |
246 | 244 | | |
| 245 | + | |
247 | 246 | | |
248 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
249 | 254 | | |
250 | 255 | | |
251 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
13 | 36 | | |
14 | 37 | | |
15 | 38 | | |
| |||
0 commit comments