Skip to content

Commit

Permalink
Install older version unless using Node v18+
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangarha committed Jan 23, 2024
1 parent 08e6c51 commit f125ff9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/generators/react_on_rails/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ def add_yarn_dependencies
babel-plugin-macros"

puts "Adding CSS handlers"
run "yarn add css-loader css-minimizer-webpack-plugin mini-css-extract-plugin style-loader"

# css_minimizer_webpack_plugin version 6 only supports Nodejs v18+
# When we bump our minimum Nodejs version to 18, we can remove this logic
# and install css_minimizer_webpack_plugin directly.
node_major_version = `node -v`.match(/^v(\d{,2})\./)[1]&.to_i
css_minimizer_webpack_plugin_version = node_major_version >= 18 ? "" : "@<6.0.0"
css_minimizer_webpack_plugin = "css-minimizer-webpack-plugin#{css_minimizer_webpack_plugin_version}"

run "yarn add css-loader '#{css_minimizer_webpack_plugin}' mini-css-extract-plugin style-loader"

puts "Adding dev dependencies"
run "yarn add -D @pmmmwh/react-refresh-webpack-plugin react-refresh"
Expand Down

0 comments on commit f125ff9

Please sign in to comment.