13
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel 5.4 + VueJS Hot Reloadについて

Posted at

Laravel5.4から、webpack-dev-serverによるhot reloadが使えます。

How to

まずは、artisanコマンドでPHPが動くサーバーを立ち上げます。

$ php artisan serve

# http://localhost:8000/

次に、npm scriptでwebpack-dev-serverを立ち上げます

$ npm run hot

# http://localhost:8080/

index.blade.phpに、webpack-dev-serverがコンパイルしたapp.jsを読み込ませるようにします。

index.blade.php
...

    <script src="http://localhost:8080/js/app.js"></script>
    </body>
</html>

これだと、deployした時に困るので、mixを使います。

index.blade.php
...

    <script src="{{ mix('js/app.js') }}"></script>
    </body>
</html>

これでリロードしなくても、VueJSの更新を終えます。

参考

13
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?