Sha256: 6a188b7dabf05735d5b7fc77dc9fc61f5c933256f039481c705d793e83a7c754

Contents?: true

Size: 1.54 KB

Versions: 21

Compression:

Stored size: 1.54 KB

Contents

require "webpacker/configuration"

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

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

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

say "Copying Elm example entry file to #{Webpacker.config.source_entry_path}"
copy_file "#{__dir__}/examples/elm/hello_elm.js",
  "#{Webpacker.config.source_entry_path}/hello_elm.js"

say "Copying Elm app file to #{Webpacker.config.source_path}"
copy_file "#{__dir__}/examples/elm/Main.elm",
  "#{Webpacker.config.source_path}/Main.elm"

say "Installing all Elm dependencies"
run "yarn add elm elm-webpack-loader"
run "yarn add --dev elm-hot-webpack-loader"
run "yarn run elm init"
run "yarn run elm make #{Webpacker.config.source_path}/Main.elm"

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

say "Updating Elm source location"
gsub_file "elm.json", /\"src\"\n/,
  %("#{Webpacker.config.source_path.relative_path_from(Rails.root)}"\n)

say "Updating .gitignore to include elm-stuff folder"
insert_into_file ".gitignore", "/elm-stuff\n", before: "/node_modules\n"

say "Webpacker now supports Elm 🎉", :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/elm.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/install/elm.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/webpacker-5.4.4/lib/install/elm.rb
webpacker-5.4.4 lib/install/elm.rb
webpacker-5.4.3 lib/install/elm.rb
webpacker-5.4.2 lib/install/elm.rb
webpacker-5.4.1 lib/install/elm.rb
webpacker-5.4.0 lib/install/elm.rb
webpacker-5.3.0 lib/install/elm.rb
webpacker-5.2.2 lib/install/elm.rb
webpacker-5.2.1 lib/install/elm.rb
webpacker-4.3.0 lib/install/elm.rb
webpacker-5.2.0 lib/install/elm.rb
webpacker-5.1.1 lib/install/elm.rb
webpacker-5.1.0 lib/install/elm.rb
webpacker-5.0.1 lib/install/elm.rb
webpacker-5.0.0 lib/install/elm.rb
webpacker-4.2.2 lib/install/elm.rb
webpacker-4.2.1 lib/install/elm.rb
webpacker-4.2.0 lib/install/elm.rb