简体   繁体   English

Fresh Laravel 5.4项目,webpack无法正常工作

[英]Fresh Laravel 5.4 Project, webpack not working

So Laravel made their new fancy wrapper for webpack called Laravel mix. 因此,Laravel为webpack制作了他们的新包装,称为Laravel mix。

According to the docs, you compile the frontend files by running npm run watch . 根据文档,您可以通过运行npm run watch编译前端文件。 The problem is that webpack doesn't detect any file changes. 问题是webpack无法检测到任何文件更改。 The only fix I've found is to add --watch-poll to the watch task config. 我发现的唯一解决方法是将--watch-poll添加到watch任务配置中。 The problem with that, is that: 问题在于:

it uses native file listeners to check for updates. 它使用本机文件侦听器检查更新。

And the problem with that is that it uses like a 105% of your CPU. 而且问题在于它占用了CPU的105%。 Do I really have to settle for this? 我真的必须为此解决吗? Is there a smarter solution for this, or even a gulp equivalent task setup for Laravel's front-end files? 是否有一个更智能的解决方案,或者甚至为Laravel的前端文件提供了等效的任务设置?

Haven't found an elegant way to do this with any gulp packages ( gulp-vueify just compiles components into js files ). 尚未找到使用任何gulp软件包执行此操作的优雅方法(gulp-vueify只是将组件编译为js文件)。

Is there any solution for Windows hosts? Windows主机有什么解决方案吗?

Thanks 谢谢

EDIT: 编辑:

Using Windows 10 and Laravel's Homestead ( NodeJS v6.9.0 ) 使用Windows 10和Laravel的Homestead(NodeJS v6.9.0)

Weird that nobody found a solution. 很奇怪没有人找到解决方案。

I found something a bit janky, but it definitely does the job. 我发现有些杂物,但绝对可以。 Find the file DirectoryWatcher.js located in /node_modules/webpack/lib/ . /node_modules/webpack/lib/找到文件DirectoryWatcher.js

On line 57 , replace the ignored option with ignored: /node_modules/, . 第57行 ,将被ignored选项替换为ignored ignored: /node_modules/, This means that any ignored option you initially pass through will get overwritten, but if I knew how to pass them in the right way, I wouldn't be doing it like this. 这意味着您最初通过的所有ignored选项都将被覆盖,但是如果我知道如何以正确的方式传递它们,我就不会那样做。

It still works fine. 它仍然可以正常工作。 CPU usage is down and compilation time is reduced greatly. CPU使用率下降,编译时间大大减少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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