Skip to content

Conversation

@ConradIrwin
Copy link

This makes it easier to figure out how to set up code-reloading of files with a .cjsx extension (I'm using https://github.com/jsdf/sprockets-coffee-react).

This makes it easier to figure out how to set up code-reloading of files with a `.cjsx` extension (I'm using https://github.com/jsdf/sprockets-coffee-react).
README.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this will only watch files that exist when you boot your development server, new files added after that will not be watched. Wouldn't it make more sense to suggest watchable_dirs here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed! Interestingly enough this approach seemed to work for me because I used Dir["#{Rails.root}/app/assets/javascripts/react/*/"]), which contained the directories too.

@xionon
Copy link
Contributor

xionon commented Feb 6, 2015

So, I finally got around to testing this, and I'm not sure that setting watchable_dirs is actually needed.

With a fresh Rails app, and both react-rails (master) and sprockets-coffee-react installed, I have no trouble in development mode getting cjsx files to auto-reload. New files and changes are both picked up on reload.

Are you putting your cjsx files in app/assets/javascripts/components?

@ConradIrwin
Copy link
Author

I'm not. They're in app/assets/javascripts/react/components.

Conrad

On Fri, Feb 6, 2015 at 8:17 AM, Alec Hipshear notifications@github.com
wrote:

So, I finally got around to testing this, and I'm not sure that setting
watchable_dirs is actually needed.

With a fresh Rails app, and both react-rails (master) and
sprockets-coffee-react installed, I have no trouble in development mode
getting cjsx files to auto-reload. New files and changes are both picked up
on reload.

Are you putting your cjsx files in app/assets/javascripts/components?


Reply to this email directly or view it on GitHub
#154 (comment).

@xionon
Copy link
Contributor

xionon commented Feb 6, 2015

That works by default for me, too...

The railtie already does basically the same thing that you add -- https://github.com/reactjs/react-rails/blob/master/lib/react/rails/railtie.rb#L19-L21

What version of Rails are you using? I'm thinking it's either a bug with our integration with previous versions of Rails, or a bug in your implementation.

@ConradIrwin
Copy link
Author

I'm using .cjsx files for coffee-script. We could change the gem to watch those too.

@xionon
Copy link
Contributor

xionon commented Feb 6, 2015

Ahhh, I see, it's a prerender issue. I misunderstood, sorry!

I'd rather not go down the path of "documenting Rails features" if we can help it. I think I would rather see a change to the railtie in the gem, maybe to watch .*jsx instead of .jsx - would that help?

@ConradIrwin
Copy link
Author

That sounds great, thanks!

Conrad

On Friday, February 6, 2015, Alec Hipshear notifications@github.com wrote:

Ahhh, I see, it's a prerender issue. I misunderstood, sorry!

I'd rather not go down the path of "documenting Rails features" if we can
help it. I think I would rather see a change to the railtie in the gem,
maybe to watch .*jsx instead of .jsx - would that help?


Reply to this email directly or view it on GitHub
#154 (comment).

@mpereira
Copy link

@xionon people using side builds with browserify or webpack might not be using files with a ".jsx" extension, but ".js" instead (my case). I had to add config.watchable_files.concat(['app/assets/javascripts/bundle.js']) to config/development.rb to get the JS VM reloading the JS bundle when it changed, for prerender. Using the latest master (99a1b38).

@dfguo
Copy link

dfguo commented Apr 15, 2015

@mpereira I'm in a similar situation. I'm using webpack, but putting

config.watchable_files.concat(['app/assets/javascripts/bundle.js']) 

to config/development.rb doesn't work for me...

@dfguo
Copy link

dfguo commented Apr 16, 2015

works after i used absolute path:

config.watchable_files.concat Dir["#{Rails.application.root}/app/assets/javascripts/bundle.js"] 
@rmosolgo
Copy link
Member

rmosolgo commented Dec 1, 2016

Sorry, I think this has been cold from even before I started maintaining this.

Please feel free to reopen if you think this is still an issue!

@rmosolgo rmosolgo closed this Dec 1, 2016
@rmosolgo
Copy link
Member

rmosolgo commented Apr 4, 2017

Using FileUpdateChecker in 2.0 will be more configurable and also catch newly-added files: #682

@chrisjingram
Copy link

If anyone lands here from Google and is still having an issue with their files not reloading in SSR, my issue was caused by react-rails not seeing the changes to .tsx files (as I'm using Typescript) and therefore not reloading the renderers.

You can tell react-rails to watch for .tsx files by adding this to your config/development.rb:

config.react.server_renderer_extensions = ["jsx", "js", "tsx", "ts"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

7 participants