elm-optimize-level-2/notes/minification.md

23 lines
807 B
Markdown
Raw Normal View History

2020-08-16 17:01:18 +03:00
# Minification
We're basically following the same protocol as [described on the Elm Guide.](https://guide.elm-lang.org/optimization/asset_size.html) We use Terser, which is just an actively maintained fork of Uglify.
2020-08-22 02:05:52 +03:00
After installing `elm-optimize-more`,
2020-08-16 17:01:18 +03:00
Install a minifier like [`Terser`](https://www.npmjs.com/package/terser).
```
npm install -g terser
```
Then, you'll want to run these commands to minify and gzip your code before deploying.
```bash
2020-08-22 02:05:52 +03:00
elm-optimize-more Main.elm --output=app.js
terser app.js --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | terser --mangle --output=app.min.js
2020-08-16 17:01:18 +03:00
gzip --keep --force app.min.js
# --keep = keep the original file
# --force = overwrite the exisign gzip file if it's there
```