elm-minify v2.0.4
Elm Minify
Minify compiled Elm modules!
Running elm make --optimize <ELM MODULE>
doesn't produce particularily small assets on its own. Running elm-minify
on these assets makes them more than 6 times smaller for my examples.
This package aims to provide whatever you need to minify the assets produced by the Elm compiler.
Get Started
The CLI is distributed through NPM. Here's how it works:
#1 install
npm i -g elm-minify
#2 compile. "--optimize" is important!
elm make --optimize --output=dist/main.js
#3 minify to "dist/main.min.js"
elm-minify dist/main.js
elm-minify
can be plugged into Webpack using this Node.js APIParcel doesn't require
elm-minify
, as it builds and minifies Elm code out of the boxMore optimizations for Elm can be found in the official guide
CLI
The CLI allows you to easily minify your Elm binaries. It has a number of flags to modify behavior described using the --help
flag:
elm-minify --help
If it doesn't fit your needs or something isn't working, let me know with a fresh issue!
Node.js API
This package exposes a node module from it's root. It gives programmatic access to elm-minify
for various purposes described here:
WebpackPlugin
() => Webpack Plugin
Plug elm-minify
into Webpack. The plugin will, running in production mode, detect when Webpack is loading files optimized with elm-webpack-loader
, and minify their content before bundling. The overhead of using this compared to the CLI is ~600 bytes for my examples. The Webpack configuration can be found here.
minify
(elmJs : String) => String
Minify compiled elm code synchronously
terserConfig
Terser Configuration
Get the Terser configuration for mangling and compressing Elm code.