Comments (12)
I've got a super simple alternative to start. Let's have a big warning message if the webpack processes are not running when an env starts up:
pgrep -fl webpack
results in this:
41545 node /Users/justin/shakacode/react_on_rails/spec/dummy/client/node_modules/.bin/webpack -w --config webpack.server.js
41546 node /Users/justin/shakacode/react_on_rails/spec/dummy/client/node_modules/.bin/webpack -w --config webpack.client.js
We don't necessarily know the config files from the setup, but we could get that.
@alexfedoseev Would it be desirable to have one webpack file generate different bundles for client and server, rather than separate config files?
@samnang This is a super fast change to make and then we are not supporting functionality that's not part of foreman.
from react_on_rails.
@justin808 I like the idea of one config for webpack.
Also I was looking at forks and it seemed like a way to background tasks while the app is running, but I didn't see how you hook it into the rails server start. Is this possible?
from react_on_rails.
We got some good info here:
http://parley.rubyrogues.com/t/invoking-subprocess-in-from-ruby/3318/5?u=railsonmaui
tmoore
Tim Moore, incrementalism.net
We've started doing something like this recently on my team at work. We're spawning a node process from the Rails app using the daemon_controller gem and then communicating to it over a pipe.
The code is here:
https://github.com/jsdf/webpack_rails
https://github.com/jsdf/ruby_node_task
It's still early days, and the code isn't heavily documented or used much outside our team, but we have been running with it for a few weeks and it has done a lot to give us the best of both worlds: Sprockets-style convenience and a modern front-end tool chain.
I'd love to see more people using and contributing to this.
from react_on_rails.
Got more info from the Ruby Rogues forum:
rob1 rob1
September 21
A simple fork should do what you want. Open file handles will be inherited by the child process, so you'll get your "standard output goes to the parent process's standard output" for free.
Something like:
if fork
exec "webpack -w --config webpack.client.js"
else
puts "in the parent, carrying on with my normal business"
end
from react_on_rails.
Would it be desirable to have one webpack file generate different bundles for client and server, rather than separate config files?
I'll answer this question in #96 PR (shakacode/react-webpack-rails-tutorial#96).
from react_on_rails.
@robwise I bet we can apply the logic of ensuring the JS is ready for tests to the problem of just running rails s
. Probably pretty easy. So keeping this one open for now.
from react_on_rails.
Yep that logic should be re-usable.
from react_on_rails.
We probably just need the startup code to call this:
https://github.com/shakacode/react_on_rails/blob/master/lib%2Freact_on_rails%2Ftest_helper.rb#L43
def self.ensure_assets_compiled(webpack_assets_status_checker: nil,
webpack_assets_compiler: nil,
webpack_process_checker: nil,
client_dir: nil,
compiled_dirs: nil)
if webpack_assets_status_checker.nil?
client_dir ||= Rails.root.join("client")
compiled_dirs ||= ReactOnRails.configuration.generated_assets_dirs
webpack_assets_status_checker ||=
WebpackAssetsStatusChecker.new(client_dir: client_dir,
compiled_dirs: compiled_dirs)
end
webpack_assets_compiler ||= WebpackAssetsCompiler.new
webpack_process_checker ||= WebpackProcessChecker.new
ReactOnRails::TestHelper::EnsureAssetsCompiled.new(
webpack_assets_status_checker: webpack_assets_status_checker,
webpack_assets_compiler: webpack_assets_compiler,
webpack_process_checker: webpack_process_checker
).call
end
We should rename the module TestHelper
to BundledAssetsHelper
to avoid confusion that this is only due to tests.
I'm guessing we would do this here:
https://github.com/shakacode/react_on_rails/blob/master/lib%2Freact_on_rails%2Fconfiguration.rb
module ReactOnRails
def self.configure
yield(configuration)
end
from react_on_rails.
There's some good comments in #289 on this in regards to how https://github.com/thoughtbot/ember-cli-rails does this.
from react_on_rails.
Can we close this? I think we should just stick with foreman or letting people manually run commands.
from react_on_rails.
@jbhatab Yes, closing. If anybody wants to help with this, I'm happy to provide guidance.
from react_on_rails.
Also, for anybody reading this, it's trivial to create your own startup script for working on the non-JS code and having the script create the JS bundles before starting Rails.
from react_on_rails.
Related Issues (20)
- Outdated link in the documentation redirects to Non-Found Page HOT 1
- Client rendering crashes when configuring `optimization.runtimeChunk` to `multiple` HOT 3
- Include Ruby 3 and node 18 to CI workflows HOT 2
- Pack generation runs with nil components_subdirectory HOT 3
- Concurrency performance HOT 3
- When server-bundle.js register a lot of server render components making the server render performance reduce big HOT 2
- Remove `request_digest` from `render_options` for version 14 HOT 1
- Convert spec/dummy/client to Typescript
- Change primary branch name from `master` to `main` HOT 2
- Add support for Vite
- Fix CI failure
- Server side rendering window behaves differently than Node.js? HOT 7
- React Component won't mount until all assets are loaded HOT 2
- Adjustment of Minimum Required Ruby Version for Versions 12.5.x HOT 5
- Webpacker constants still being referenced HOT 1
- Clarification and reorganization of test conditions in configuration specs HOT 2
- `react_on_rails:generate_packs` should add the import statement to the entry point even if the packs already exist
- Bump Rescript in examples due to build-time errors HOT 2
- How to refresh CSRF token? HOT 4
- uninitialized constant `ReactOnRails::Configuration::Webpacker` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react_on_rails.