https://github.com/sam0x17/es6-minifier
A self-contained crystal shard that can minify ES6+ JavaScript.
https://github.com/sam0x17/es6-minifier
crystal-language crystal-shard minifier minify-javascript
Last synced: about 2 months ago
JSON representation
A self-contained crystal shard that can minify ES6+ JavaScript.
- Host: GitHub
- URL: https://github.com/sam0x17/es6-minifier
- Owner: sam0x17
- License: mit
- Created: 2020-06-24T22:53:12.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-21T14:58:17.000Z (almost 3 years ago)
- Last Synced: 2025-02-05T21:27:40.632Z (3 months ago)
- Topics: crystal-language, crystal-shard, minifier, minify-javascript
- Language: Shell
- Homepage:
- Size: 660 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# es6-minifier
Embeds Terser (current standard es6 minification tool in the NPM ecosystem) in
a crystal shard via a cross-platform pkg-powered binary that embeds Terser
in a lightweight portable nodejs environment. No nodejs required.## Usage
Just install
the shard and you can minify your ES6+ Javascript as follows:```crystal
require "es6-minifier"Es6Minifier.minify!("const something = 3;") # => "const something=3;"
Es6Minifier.minify!(["file1.js", "file2.js"])
# file1.js and file2.js are overwritten with a minified version of their contents
```If a parsing or IO error occurs, `Es6Minifier.minify!` will throw an error.
Right now there are no configurable options however this could be easily
added by passing JSON options to `minify.js` and adding a bit of code
on the crystal side. Pull requests welcome!Currently supports linux, macos, and alpine. Could easily support FreeBSD
and Windows with a several line change.## Installation
Just add the following to yoour `shard.yml`:
```
dependencies:
es6-minifier:
github: sam0x17/es6-minifier
```