Laravel 中的 npm run watch 和 npm run hot 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45162697/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the difference between npm run watch and npm run hot in Laravel?
提问by Ayon Lee
Because these commands are both available in Laravel, I don't quite understand what's the difference between them. But I do notice that npm run hot
would not be effected if I changed scss files, which npm run watch
will perform correctly.
因为这些命令在 Laravel 中都是可用的,所以我不太明白它们之间有什么区别。但我确实注意到,npm run hot
如果我更改了 scss 文件,它将不会受到影响,这npm run watch
将正确执行。
回答by mufaddal_mw
Hot Module Replacement (or Hot Reloading) allows you to, not just refresh the page when a piece of JavaScript is changed, but it will also maintain the current state of the component in the browser.Check full documentation here
Hot Module Replacement(或Hot Reloading)使您不仅可以在更改JavaScript 片段时刷新页面,还可以在浏览器中保持组件的当前状态。在此处查看完整文档
回答by Pave
It won't work right now for regular Sass files. The HMR feature is specifically for Vue and .vue components.
它现在不适用于常规 Sass 文件。HMR 功能专门用于 Vue 和 .vue 组件。
https://github.com/JeffreyWay/laravel-mix/issues/92#issuecomment-273558018https://github.com/JeffreyWay/laravel-mix/issues/233
https://github.com/JeffreyWay/laravel-mix/issues/92#issuecomment-273558018 https://github.com/JeffreyWay/laravel-mix/issues/233
If you are curious what the HMR actually means, you can refer to the official docs: https://webpack.js.org/guides/hot-module-replacement/
如果您好奇 HMR 的实际含义,可以参考官方文档:https: //webpack.js.org/guides/hot-module-replacement/