Sha256: 9e86e87c6b812b7668ac19a6b6ecdc4c5cefd7fcac453e94b0c64bc79c181047

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

unless Bridgetown::Utils.frontend_bundler_type == :esbuild
  error_message = "#{"esbuild.config.js".bold} not found. (This configuration doesn't currently " \
                  "support Webpack.)"

  @logger.error "\nError:".red, "🚨 #{error_message}"

  return
end

say_status :ruby2js, "Installing Ruby2JS..."

add_gem "ruby2js"
add_npm_package "-D @ruby2js/esbuild-plugin"

insert_into_file "esbuild.config.js",
                 after: 'const build = require("./config/esbuild.defaults.js")' do
  <<~JS

    const ruby2js = require("@ruby2js/esbuild-plugin")
  JS
end

insert_into_file "esbuild.config.js",
                 after: "\n  plugins: [\n" do
  <<-JS
    ruby2js(),
  JS
end

copy_file in_templates_dir("ruby2js.rb"), "config/ruby2js.rb"
copy_file in_templates_dir("hello_world.js.rb"), "src/_components/hello_world.js.rb"

say_status :ruby2js, "Ruby2JS is now configured!"

say "Check out the example `hello_world.js.rb` file in `src/_components`", :blue
say "Ruby2JS configuration options are saved in `config/ruby2js.rb`", :blue
say 'For further reading, check out "https://www.ruby2js.com"', :blue

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bridgetown-core-2.0.0.beta3 lib/bridgetown-core/configurations/ruby2js.rb
bridgetown-core-2.0.0.beta2 lib/bridgetown-core/configurations/ruby2js.rb
bridgetown-core-2.0.0.beta1 lib/bridgetown-core/configurations/ruby2js.rb