Skip to content

Commit 59f7815

Browse files
justin808claude
andcommitted
Fix CSS module configuration issues in generator examples
Fixes: - Replace CSS modules with regular CSS imports in HelloWorld templates - Rename HelloWorld.module.css files to HelloWorld.css - Update import statements from CSS modules syntax to regular CSS imports - Update generator copy operations to reference renamed CSS files This resolves webpack compilation errors in generated examples: - ERROR: Module parse failed: Unexpected token (1:0) - You may need an appropriate loader to handle this file type Changes: - HelloWorld components now use className="bright" instead of className={style.bright} - CSS files use standard class names instead of CSS module exports - All HelloWorld templates (base, redux, client, server) updated consistently Technical rationale: CSS modules require additional webpack configuration and loader setup that's not available by default in Shakapacker 8.x. Using regular CSS imports provides the same styling functionality with simpler configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 36f04d8 commit 59f7815

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

lib/generators/react_on_rails/base_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def copy_js_bundle_files
4949
base_path = "base/base/"
5050
base_files = %w[app/javascript/packs/server-bundle.js]
5151

52-
# Only copy HelloWorld.module.css for non-Redux components
52+
# Only copy HelloWorld.css for non-Redux components
5353
# Redux components handle their own CSS files
54-
base_files << "app/javascript/src/HelloWorld/HelloWorld.module.css" unless options.redux?
54+
base_files << "app/javascript/src/HelloWorld/HelloWorld.css" unless options.redux?
5555

5656
base_files.each { |file| copy_file("#{base_path}#{file}", file) }
5757
end

lib/generators/react_on_rails/react_with_redux_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def copy_base_files
2525
"app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.client.jsx")
2626
copy_file("#{base_js_path}/app/javascript/bundles/HelloWorld/startup/HelloWorldApp.server.jsx",
2727
"app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.server.jsx")
28-
copy_file("#{base_js_path}/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css",
29-
"app/javascript/src/HelloWorldApp/components/HelloWorld.module.css")
28+
copy_file("#{base_js_path}/app/javascript/bundles/HelloWorld/components/HelloWorld.css",
29+
"app/javascript/src/HelloWorldApp/components/HelloWorld.css")
3030

3131
# Update import paths in client component
3232
ror_client_file = "app/javascript/src/HelloWorldApp/ror_components/HelloWorldApp.client.jsx"

lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React, { useState } from 'react';
3-
import * as style from './HelloWorld.module.css';
3+
import './HelloWorld.css';
44

55
const HelloWorld = (props) => {
66
const [name, setName] = useState(props.name);
@@ -10,7 +10,7 @@ const HelloWorld = (props) => {
1010
<h3>Hello, {name}!</h3>
1111
<hr />
1212
<form>
13-
<label className={style.bright} htmlFor="name">
13+
<label className="bright" htmlFor="name">
1414
Say hello to:
1515
<input id="name" type="text" value={name} onChange={(e) => setName(e.target.value)} />
1616
</label>

lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React, { useState } from 'react';
3-
import * as style from '../HelloWorld.module.css';
3+
import '../HelloWorld.css';
44

55
const HelloWorld = (props) => {
66
const [name, setName] = useState(props.name);
@@ -10,7 +10,7 @@ const HelloWorld = (props) => {
1010
<h3>Hello, {name}!</h3>
1111
<hr />
1212
<form>
13-
<label className={style.bright} htmlFor="name">
13+
<label className="bright" htmlFor="name">
1414
Say hello to:
1515
<input id="name" type="text" value={name} onChange={(e) => setName(e.target.value)} />
1616
</label>

lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import * as style from './HelloWorld.module.css';
3+
import './HelloWorld.css';
44

55
const HelloWorld = ({ name, updateName }) => (
66
<div>
@@ -10,7 +10,7 @@ const HelloWorld = ({ name, updateName }) => (
1010
</h3>
1111
<hr />
1212
<form>
13-
<label className={style.bright} htmlFor="name">
13+
<label className="bright" htmlFor="name">
1414
Say hello to:
1515
<input id="name" type="text" value={name} onChange={(e) => updateName(e.target.value)} />
1616
</label>

0 commit comments

Comments
 (0)