0

I am having trouble getting hot reloading to work with my laravel app.

//laravel homepage

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Laravel</title>
</head>
<body>
    <div id="root"></div>
<?php
    if (App::isLocal()):
?>
    <script type="text/javascript" src="http://localhost:3000/static/bundle.js"></script>
<?php else: ?>
    <script type="text/javascript" src="/dist/bundle.js"></script>
<?php endif; ?>
</body>
</html>

When I go to my homestead laravel backend page (localhost:8000), everything works fine, but there's no hot reloading when I change react components.

When I go directly to the dev-server http://localhost:3000 I get hot reloading.

I am using the react transform boilerplate: https://github.com/gaearon/react-transform-boilerplate

How can I get the backend laravel page to reload the bundle?

DrivingInsanee
  • 1,631
  • 2
  • 13
  • 22
  • Just a suggestion, why don't you use the blade directive `@if @else @endif` instead of the messy php syntax. [This is not a solution] – Jilson Thomas Feb 08 '16 at 14:43
  • Honestly, I just didn't bother looking into blade at all. Im actually going to do that now. – DrivingInsanee Feb 08 '16 at 14:48
  • Did you ever get an answer to this question? – Dolbex Apr 27 '16 at 22:14
  • Can you share your webpack-dev-server configuration. You will actually have to use it as a proxy to Laravel server. If you want a solution based on BrowserSync, then I have created a Laravel Elixir extension for it - [laravel-elixir-react-hmr](https://www.npmjs.com/package/laravel-elixir-react-hmr) – Pawan Samdani Sep 29 '16 at 11:36

1 Answers1

0

change
src="http://localhost:3000/static/bundle.js"
to
src="{{url('static/bundle.js)'}}"
and

src="/dist/bundle.js"

to

src="{{url('/dist/bundle.js')}}"
paranoid
  • 6,799
  • 19
  • 49
  • 86