Skip to content

Commit bac0985

Browse files
justin808claude
andcommitted
Run react_on_rails:install generator
- Run rails generate react_on_rails:install - Configure Shakapacker webpack integration - Add HelloWorld example component and controller - Set up webpack configuration for client and server bundles - Add Procfile.dev variants for different asset modes - Configure babel for React development - Install npm dependencies for webpack and React - Fix RuboCop linting issues in generated files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 354fe19 commit bac0985

31 files changed

+6746
-1
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,14 @@
3232

3333
# Ignore master key for decrypting credentials and more.
3434
/config/master.key
35+
36+
/public/packs
37+
/public/packs-test
38+
/node_modules
39+
/yarn-error.log
40+
yarn-debug.log*
41+
.yarn-integrity
42+
43+
# Generated React on Rails packs
44+
**/generated/**
45+
ssr-generated

Procfile.dev

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Procfile for development using HMR
2+
# You can run these commands in separate shells
3+
rails: bundle exec rails s -p 3000
4+
wp-client: WEBPACK_SERVE=true bin/shakapacker-dev-server
5+
wp-server: SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch

Procfile.dev-prod-assets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Procfile for development with production assets
2+
# Uses production-optimized, precompiled assets with development environment
3+
# Uncomment additional processes as needed for your app
4+
5+
rails: bundle exec rails s -p 3001
6+
# sidekiq: bundle exec sidekiq -C config/sidekiq.yml
7+
# redis: redis-server
8+
# mailcatcher: mailcatcher --foreground

Procfile.dev-static-assets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: bin/rails server -p 3000
2+
js: bin/shakapacker --watch
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
class HelloWorldController < ApplicationController
4+
layout "hello_world"
5+
6+
def index
7+
@hello_world_props = { name: "Stranger" }
8+
end
9+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint no-console:0 */
2+
// This file is automatically compiled by Webpack, along with any other files
3+
// present in this directory. You're encouraged to place your actual application logic in
4+
// a relevant structure within app/javascript and only use these pack files to reference
5+
// that code so it'll be compiled.
6+
//
7+
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8+
// layout file, like app/views/layouts/application.html.erb
9+
10+
// Uncomment to copy all static images under ./images to the output folder and reference
11+
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
12+
// or the `imagePath` JavaScript helper below.
13+
//
14+
// const images = require.context('./images', true)
15+
// const imagePath = (name) => images(name, true)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Placeholder comment - auto-generated imports will be prepended here by react_on_rails:generate_packs
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { useState } from 'react';
2+
import * as style from './HelloWorld.module.css';
3+
4+
const HelloWorld = (props) => {
5+
const [name, setName] = useState(props.name);
6+
7+
return (
8+
<div>
9+
<h3>Hello, {name}!</h3>
10+
<hr />
11+
<form>
12+
<label className={style.bright} htmlFor="name">
13+
Say hello to:
14+
<input id="name" type="text" value={name} onChange={(e) => setName(e.target.value)} />
15+
</label>
16+
</form>
17+
</div>
18+
);
19+
};
20+
21+
export default HelloWorld;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.bright {
2+
color: green;
3+
font-weight: bold;
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import HelloWorld from './HelloWorld.client';
2+
// This could be specialized for server rendering
3+
// For example, if using React Router, we'd have the SSR setup here.
4+
5+
export default HelloWorld;

0 commit comments

Comments
 (0)