最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Laravel npm run watch not compile in runtime scss and js - Stack Overflow

programmeradmin1浏览0评论

Hi I have issue with new laravel project. I know it should be autopile scss and js after mand 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 piling 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 piling 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....

Hi I have issue with new laravel project. I know it should be autopile scss and js after mand 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 piling 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 piling 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....

Share Improve this question edited Jul 14, 2020 at 8:00 Young L. asked Jul 14, 2020 at 7:51 Young L.Young L. 1,0424 gold badges19 silver badges37 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 3

first run

npm run dev

then run

npm run watch

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

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 mands:

  • npm run dev
  • 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

In my case, the npm upgrade solved the issue.

发布评论

评论列表(0)

  1. 暂无评论