Sha256: c7e16aeccbe5378c50ab261d1e39f46a19ba6f8897492e884397c266c42b829a

Contents?: true

Size: 1023 Bytes

Versions: 21

Compression:

Stored size: 1023 Bytes

Contents

require "webpacker/configuration"

say "Copying erb loader to config/webpack/loaders"
copy_file "#{__dir__}/loaders/erb.js", Rails.root.join("config/webpack/loaders/erb.js").to_s

say "Adding erb loader to config/webpack/environment.js"
insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
  "const erb = require('./loaders/erb')\n",
  after: /require\(('|")@rails\/webpacker\1\);?\n/

insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
  "environment.loaders.prepend('erb', erb)\n",
  before: "module.exports"

say "Updating webpack paths to include .erb file extension"
insert_into_file Webpacker.config.config_path, "- .erb\n".indent(4), after: /\s+extensions:\n/

say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
copy_file "#{__dir__}/examples/erb/hello_erb.js.erb",
  "#{Webpacker.config.source_entry_path}/hello_erb.js.erb"

say "Installing all Erb dependencies"
run "yarn add rails-erb-loader"

say "Webpacker now supports Erb in JS 🎉", :green

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/install/erb.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/install/erb.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/install/erb.rb
webpacker-5.4.4 lib/install/erb.rb
webpacker-5.4.3 lib/install/erb.rb
webpacker-5.4.2 lib/install/erb.rb
webpacker-5.4.1 lib/install/erb.rb
webpacker-5.4.0 lib/install/erb.rb
webpacker-5.3.0 lib/install/erb.rb
webpacker-5.2.2 lib/install/erb.rb
webpacker-5.2.1 lib/install/erb.rb
webpacker-4.3.0 lib/install/erb.rb
webpacker-5.2.0 lib/install/erb.rb
webpacker-5.1.1 lib/install/erb.rb
webpacker-5.1.0 lib/install/erb.rb
webpacker-5.0.1 lib/install/erb.rb
webpacker-5.0.0 lib/install/erb.rb
webpacker-4.2.2 lib/install/erb.rb
webpacker-4.2.1 lib/install/erb.rb
webpacker-4.2.0 lib/install/erb.rb