Skip to content

Commit 9b40a29

Browse files
bkuhlmanngauravtiwari
authored andcommitted
Fixed Elm install issue with older Webpacker gem versions. (#356)
* Refactored Elm install script grouping of operations. - Organizes the script so that there is a logical grouping of operations (this'll have more relevanace in the next commit): - copying - installing - updating * Updated Elm install script to update `paths.yml`. - Resolves an edge case where one could have installed an older version of this gem, upgrade, and then run `rails webpacker:install:elm` only realize that the `paths.yml` file wasn't updated because the Elm extension was only added in a new version of this gem. - Ensures the Elm script is self-contained and all modifications needed to support Elm via Webpack is within this script only. * Removed Elm extension from `paths.yml`. - Now that the Elm script has the knowledge to update this file appropriately (see previous commit), this entry no longer needs to exist as it'll be dynamically added during Elm install script execution.
1 parent cf44b8c commit 9b40a29

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/install/config/webpack/paths.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ default: &default
99
source: app/javascript
1010
extensions:
1111
- .coffee
12-
- .elm
1312
- .js
1413
- .jsx
1514
- .ts

lib/install/elm.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@
1111
copy_file "#{__dir__}/examples/elm/hello_elm.js",
1212
"#{Webpacker::Configuration.entry_path}/hello_elm.js"
1313

14-
puts "Updating .gitignore to include elm-stuff folder"
15-
insert_into_file ".gitignore", "/elm-stuff\n", before: "/node_modules\n"
16-
1714
puts "Installing all elm dependencies"
1815
exec "#{RbConfig.ruby} ./bin/yarn add elm"
1916
exec "#{RbConfig.ruby} ./bin/yarn add --dev elm-hot-loader elm-webpack-loader"
2017
run "yarn run elm package install -- --yes"
2118

19+
puts "Updating Webpack paths to include Elm file extension"
20+
insert_into_file Webpacker::Configuration.file_path, " - .elm\n", after: /extensions:\n/
21+
2222
puts "Updating elm source location"
2323
source_path = File.join Webpacker::Configuration.source, Webpacker::Configuration.paths.fetch(:entry, "packs")
2424
gsub_file "elm-package.json", /\"\.\"\n/, %("#{source_path}"\n)
2525

26+
puts "Updating .gitignore to include elm-stuff folder"
27+
insert_into_file ".gitignore", "/elm-stuff\n", before: "/node_modules\n"
28+
2629
puts "Webpacker now supports elm 🎉"

0 commit comments

Comments
 (0)