简体   繁体   中英

Laravel npm run watch not compile in runtime scss and js

Hi I have issue with new laravel project. I know it should be autocompile scss and js after command npm run watch. But it not recognized any changes and i don t know why.

My webpack.mix.js looks like this:

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css');

For compiling a changes i have to put every time npm run watch. Please if you know why let me know.

Log from console:
 DONE  Compiled successfully in 8794ms                                7:57:59 AM

       Asset      Size   Chunks             Chunk Names
/css/app.css   179 KiB  /js/app  [emitted]  /js/app
  /js/app.js  1.66 MiB  /js/app  [emitted]  /js/app

But this never changed in runtime....

first run

npm run dev

then run

npm run watch

Oh I run npm run watch on homestead server... When i try it in local enviroment it works fine. This is solution

I tried the following steps to clean the public folder and it solved the issue for me.

Delete the following files from the public folder:

  • mix-manifest.json
  • All files inside the js folder
  • Any file named in numeric, ex: 123.js

Then run the following commands:

  • npm run dev
  • npm run watch

Try npm run watch-poll . Watch command don't always work. So watch-poll checks for file changes manually every few milliseconds.

In my case, the npm upgrade solved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM