Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict css-minimizer-webpack-plugin version in the generator unless using Node v18+ #1598

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading