File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,43 @@ Bundler::GemHelper.install_tasks
44
55require 'opal/spec/rake_task'
66Opal ::Spec ::RakeTask . new ( :default )
7+
8+ desc "Build build/opal-jquery.js"
9+ task :dist do
10+ require 'fileutils'
11+ FileUtils . mkdir_p 'build'
12+
13+ src = Opal ::Builder . build ( 'opal-jquery' )
14+ min = uglify src
15+ gzp = gzip min
16+
17+ File . open ( 'build/opal-jquery.js' , 'w+' ) do |out |
18+ out << src
19+ end
20+
21+ puts "development: #{ src . size } , minified: #{ min . size } , gzipped: #{ gzp . size } "
22+ end
23+
24+ # Used for uglifying source to minify
25+ def uglify ( str )
26+ IO . popen ( 'uglifyjs' , 'r+' ) do |i |
27+ i . puts str
28+ i . close_write
29+ return i . read
30+ end
31+ rescue Errno ::ENOENT
32+ $stderr. puts '"uglifyjs" command not found (install with: "npm install -g uglify-js")'
33+ nil
34+ end
35+
36+ # Gzip code to check file size
37+ def gzip ( str )
38+ IO . popen ( 'gzip -f' , 'r+' ) do |i |
39+ i . puts str
40+ i . close_write
41+ return i . read
42+ end
43+ rescue Errno ::ENOENT
44+ $stderr. puts '"gzip" command not found, it is required to produce the .gz version'
45+ nil
46+ end
You can’t perform that action at this time.
0 commit comments