Module: Opal::Util

Extended by:
Util
Included in:
Util
Defined in:
lib/opal/util.rb

Constant Summary collapse

ExitStatusError =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#gzip(source) ⇒ Object

Gzip code to check file size.



22
23
24
# File 'lib/opal/util.rb', line 22

def gzip(source)
  sh 'gzip -f', data: source
end

#uglify(source, mangle: false) ⇒ String

Used for uglifying source to minify.

Opal::Util.uglify("javascript contents")

Parameters:

  • str (String)

    string to minify

Returns:

  • (String)


17
18
19
# File 'lib/opal/util.rb', line 17

def uglify(source, mangle: false)
  sh "#{'ruby ' if Gem.win_platform?}bin/yarn -s run terser -c #{'-m' if mangle}", data: source
end