From 76c6b50d9814fda73c9eb33ef36fe869947573ed Mon Sep 17 00:00:00 2001 From: Mikhail Boutylin Date: Tue, 25 Jun 2024 06:54:23 +0400 Subject: [PATCH] fixed css-loader instalation and css import in example files (#1634) Related to https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#-breaking-changes --- CHANGELOG.md | 2 ++ lib/generators/react_on_rails/base_generator.rb | 5 +++-- .../javascript/bundles/HelloWorld/components/HelloWorld.jsx | 2 +- .../javascript/bundles/HelloWorld/components/HelloWorld.jsx | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5d5396a..c78b1ff73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac ### [Unreleased] Changes since the last non-beta release. +#### Fixed +- Fixed css-loader installation with [PR 1634](https://github.com/shakacode/react_on_rails/pull/1634) by [vaukalak](https://github.com/vaukalak) #### Fixed - Address a number of typos and grammar mistakes [PR 1631](https://github.com/shakacode/react_on_rails/pull/1631) by [G-Rath](https://github.com/G-Rath) diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index cecd0868a..83088444a 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -40,7 +40,8 @@ def copy_base_files def copy_js_bundle_files base_path = "base/base/" base_files = %w[app/javascript/packs/server-bundle.js - app/javascript/bundles/HelloWorld/components/HelloWorldServer.js] + app/javascript/bundles/HelloWorld/components/HelloWorldServer.js + app/javascript/bundles/HelloWorld/components/HelloWorld.module.css] base_files.each { |file| copy_file("#{base_path}#{file}", file) } end @@ -91,7 +92,7 @@ def add_yarn_dependencies puts "Adding CSS handlers" - run "yarn add css-loader css-minimizer-webpack-plugin mini-css-extract-plugin style-loader@" + run "yarn add -D 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" diff --git a/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx b/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx index 70cff370f..35fef108f 100644 --- a/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +++ b/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React, { useState } from 'react'; -import style from './HelloWorld.module.css'; +import * as style from './HelloWorld.module.css'; const HelloWorld = (props) => { const [name, setName] = useState(props.name); diff --git a/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx b/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx index 211819924..2112bcc3d 100644 --- a/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +++ b/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; -import style from './HelloWorld.module.css'; +import * as style from './HelloWorld.module.css'; const HelloWorld = ({ name, updateName }) => (