I tried to upgrade to use Opal 0.7.0.beta. I want to compile to a static app and follow the steps in http://opalrb.org/docs/static_applications/
My Rakefile looks like the one below. The questions:
How do I need to rework the :build task to get rid of the deprecation message. i tried. to use Opal::Server instead of Opal::Environment but it did not work.
I get `Opal already loaded. Loading twice can cause troubles, please fix your setup.``
I get undefined is not a function
in the generated javascript Opal.mark_as_loaded(Opal.normalize_loadable_path("corelib/runtime"));
Thanks for Opal and thanks for any advice.
# Rakefile
require 'opal'
require 'opal/sprockets/environment'
require 'opal-jquery'
require 'erb'
require 'zip'
ZUPFNOTER_JS = "../deploy_files/build.js"
desc "Build our app to #{ZUPFNOTER_JS}"
task :build do
env = Opal::Environment.new
env.append_path "."
env.use_gem "vector2d"
File.open(ZUPFNOTER_JS, "w+") do |out|
out << env["application"].to_s
end
Dir.glob "../public/*.scss" do |f|
cmd = "sass #{f} > #{File.dirname(f)}/#{File.basename(f, ".scss")}.css"
puts sh cmd
end
end
...
Something like the following should work:
require 'opal'
task :build do
env = Sprockets::Environment.new
Opal.append_path '.'
Opal.use_gem 'vector2d'
Opal.paths.each { |p| env.append_path(p) }
File.open(ZUPFNOTER_JS, 'w+') { |out| out << env['application.js'].to_s }
# …
end
I also suggest to use the same sprockets environment to build SCSS too as it should work out of the box (maybe a require "sass"
is needed too).
Issue #2: it is enough to require opal
; there is no need to load the opal.min.js
in the HTML page.
Issue #3: The loaded opal.min.js
was of 0.6.1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.