Skip to content

Commit 1dea0e6

Browse files
justin808claude
andcommitted
Improve development setup and webpack configuration
- Increase Procfile.dev sleep timers from 5s to 15s to ensure ReScript initial build completes - Comment out redis-server in Procfile (run as system service instead) - Add locale generation to build_production_command - Change dev_server.https to dev_server.server in shakapacker.yml - Disable ReactRefreshWebpackPlugin for rspack compatibility - Add comments documenting Procfile processes Related to precompile hook coordination issues: - shakacode/shakapacker#849 - shakacode/react_on_rails#2090 - shakacode/react_on_rails#2091 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 80df3b5 commit 1dea0e6

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

Procfile.dev

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Procfile for development using HMR
22
# You can run these commands in separate shells
3+
# ReScript: clean and rebuild, then watch for changes
34
rescript: yarn res:dev
4-
redis: redis-server
5+
# redis: redis-server # Run Redis as a system service instead (brew services start redis)
56
rails: bundle exec thrust bin/rails server -p 3000
67
# Sleep to allow rescript files to compile before starting webpack
7-
wp-client: sleep 5 && RAILS_ENV=development NODE_ENV=development bin/shakapacker-dev-server
8-
wp-server: sleep 5 && bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch
8+
# Increased sleep time to ensure rescript initial build completes
9+
wp-client: sleep 15 && RAILS_ENV=development NODE_ENV=development bin/shakapacker-dev-server
10+
wp-server: sleep 15 && bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch

config/initializers/react_on_rails.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
config.components_subdirectory = "ror_components"
77
config.auto_load_bundle = true
88

9+
# Build commands with locale generation
910
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
10-
config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker"
11+
config.build_production_command = "bundle exec rake react_on_rails:locale && RAILS_ENV=production NODE_ENV=production bin/shakapacker"
1112

1213
# This is the file used for server rendering of React when using `(prerender: true)`
1314
# If you are never using server rendering, you may set this to "".

config/shakapacker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ development:
2828

2929
# Reference: https://webpack.js.org/configuration/dev-server/
3030
dev_server:
31-
https: false
31+
server: http
3232
host: localhost
3333
port: 3035
3434
# Hot Module Replacement updates modules while the application is running without a full reload

config/webpack/development.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
55

6-
const { devServer, inliningCss } = require('shakapacker');
6+
const { devServer, inliningCss, config } = require('shakapacker');
77

88
const webpackConfig = require('./webpackConfig');
99

@@ -13,15 +13,19 @@ const developmentEnvOnly = (clientWebpackConfig, _serverWebpackConfig) => {
1313
// Note, when this is run, we're building the server and client bundles in separate processes.
1414
// Thus, this plugin is not applied to the server bundle.
1515

16-
// eslint-disable-next-line global-require
17-
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
18-
clientWebpackConfig.plugins.push(
19-
new ReactRefreshWebpackPlugin({
20-
overlay: {
21-
sockPort: devServer.port,
22-
},
23-
}),
24-
);
16+
// ReactRefreshWebpackPlugin is not compatible with rspack
17+
const isRspack = config.assets_bundler === 'rspack';
18+
if (!isRspack) {
19+
// eslint-disable-next-line global-require
20+
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
21+
clientWebpackConfig.plugins.push(
22+
new ReactRefreshWebpackPlugin({
23+
overlay: {
24+
sockPort: devServer.port,
25+
},
26+
}),
27+
);
28+
}
2529
}
2630
};
2731

0 commit comments

Comments
 (0)