Laravel project auto refresh after changes

前端 未结 2 601
渐次进展
渐次进展 2021-01-03 06:34

Does anyone know if there is a way to run the code changes in a Laravel project without refreshing the page every time.

I know that to see the chang

相关标签:
2条回答
  • 2021-01-03 06:59

    You can achieve this with Laravel Mix.

    According to this part of the documentation, you need to edit your webpack.mix.js file, and add this to the end:

    mix.browserSync('127.0.0.1:8000');
    

    It needs to match to the output of the php artisan serve command, where you found a line something like this:

    Laravel development server started: <http://127.0.0.1:8000>
    

    After this, you have to run the php artisan serve, and the npm run watch command simultaneously. You must leave to run both commands while you edit your files.

    Note: The first time you run the npm run watch, it installs additional components. But the command output is quite clear on that. If everything is in order, Laravel Mix automatically opens your browser with http://localhost:3000, or something like this.

    0 讨论(0)
  • 2021-01-03 07:02

    add in webpack.max.js file in laravel

    mix.browserSync('127.0.0.1:8000');
    

    then run this command

    > npm install browser-sync browser-sync-webpack-plugin@2.0.1 --save-dev --production=false
    

    after this run npm run watch

    > Browsersync automatic run your port 3000
    
    0 讨论(0)
提交回复
热议问题