Merge pull request #42621 from SkipKayhil/docs-terser

[ci skip] replace Uglifier example with Terser
This commit is contained in:
Zachary Scott 2021-06-28 08:04:38 +09:00 committed by GitHub
commit f73b777adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

@ -1068,20 +1068,20 @@ Possible options for JavaScript compression are `:terser`, `:closure`, `:uglifie
`:yui`. These require the use of the `terser`, `closure-compiler`, `uglifier` or `:yui`. These require the use of the `terser`, `closure-compiler`, `uglifier` or
`yui-compressor` gems, respectively. `yui-compressor` gems, respectively.
Take the `uglifier` gem, for example. Take the `terser` gem, for example.
This gem wraps [UglifyJS](https://github.com/mishoo/UglifyJS) (written for This gem wraps [Terser](https://github.com/terser/terser) (written for
NodeJS) in Ruby. It compresses your code by removing white space and comments, NodeJS) in Ruby. It compresses your code by removing white space and comments,
shortening local variable names, and performing other micro-optimizations such shortening local variable names, and performing other micro-optimizations such
as changing `if` and `else` statements to ternary operators where possible. as changing `if` and `else` statements to ternary operators where possible.
The following line invokes `uglifier` for JavaScript compression. The following line invokes `terser` for JavaScript compression.
```ruby ```ruby
config.assets.js_compressor = :uglifier config.assets.js_compressor = :terser
``` ```
NOTE: You will need an [ExecJS](https://github.com/rails/execjs#readme) NOTE: You will need an [ExecJS](https://github.com/rails/execjs#readme)
supported runtime in order to use `uglifier`. If you are using macOS or supported runtime in order to use `terser`. If you are using macOS or
Windows you have a JavaScript runtime installed in your operating system. Windows you have a JavaScript runtime installed in your operating system.
### GZipping your assets ### GZipping your assets

@ -172,7 +172,7 @@ pipeline is enabled. It is set to `true` by default.
* `config.assets.css_compressor` defines the CSS compressor to use. It is set by default by `sass-rails`. The unique alternative value at the moment is `:yui`, which uses the `yui-compressor` gem. * `config.assets.css_compressor` defines the CSS compressor to use. It is set by default by `sass-rails`. The unique alternative value at the moment is `:yui`, which uses the `yui-compressor` gem.
* `config.assets.js_compressor` defines the JavaScript compressor to use. Possible values are `:closure`, `:uglifier` and `:yui` which require the use of the `closure-compiler`, `uglifier` or `yui-compressor` gems respectively. * `config.assets.js_compressor` defines the JavaScript compressor to use. Possible values are `:terser`, `:closure`, `:uglifier` and `:yui` which require the use of the `terser`, `closure-compiler`, `uglifier` or `yui-compressor` gems respectively.
* `config.assets.gzip` a flag that enables the creation of gzipped version of compiled assets, along with non-gzipped assets. Set to `true` by default. * `config.assets.gzip` a flag that enables the creation of gzipped version of compiled assets, along with non-gzipped assets. Set to `true` by default.