简体   繁体   English

Laravel Mix 'watch' 在 webpack.mix.js 更新时无法编译

[英]Laravel Mix 'watch' not compiling when webpack.mix.js updated

When I run npm run watch and update my source .js and .scss assets, the compilation is run automatically as expected.当我运行npm run watch并更新我的源.js.scss资产时,编译会按预期自动运行。 When I update the webpack.mix.js file, the changes are NOT compiled automatically.当我更新webpack.mix.js文件时,更改不会自动编译。

Is this something that v6 doesn't support?这是v6不支持的东西吗? Because v5 did work as expected.因为 v5 确实按预期工作。

The config:配置:

const mix = require('laravel-mix')

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

package.json : package.json

{
  ...

  "scripts": {
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options-poll=1000",
    "hot": "mix watch --hot",
    "production": "mix --production"
  }

  ...
}

Weird, it works for me.奇怪,它对我有用。 Have you tried npm run watch-poll instead?您是否尝试过npm run watch-poll Are you running the latest version of Laravel Mix?您运行的是最新版本的 Laravel Mix 吗?

"laravel-mix": "^6.0.11",

Unrelated, you may want to update your package.json to the following if you're using Laravel Mix 6.无关,如果您使用 Laravel Mix 6,您可能需要将 package.json 更新为以下内容

"scripts": {
    "dev": "npm run development",
    "development": "mix",
    "watch": "mix watch",
    "watch-poll": "mix watch -- --watch-options-poll=1000",
    "hot": "mix watch --hot",
    "prod": "npm run production",
    "production": "mix --production"
},

According to 8.x Laravel Docs...根据 8.x Laravel 文档...

Webpack may not be able to detect your file changes in certain local development environments. Webpack 在某些本地开发环境中可能无法检测到您的文件更改。 If this is the case on your system, consider using the watch-poll command.如果您的系统出现这种情况,请考虑使用 watch-poll 命令。

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

相关问题 如何在Laravel webpack.mix.js中添加全局函数? - How to add global functions in Laravel webpack.mix.js? mix.scripts无法正常工作(webpack.mix.js) - mix.scripts is not working (webpack.mix.js) Laravel Mix / Webpack不会在通过babel()编译的脚本上触发监视功能 - Laravel mix / webpack not triggering the watch functionality on scripts compiling through babel() 为什么在构建 webpack.mix.js 时我的.css 文件不会出现在公共目录中? - Why won't my .css file show up in the public directory when building webpack.mix.js? 使用 webpack.mix 编译 js 文件时,mix.scripts 在 laravel 5.5 上不起作用 - mix.scripts doesn't work on laravel 5.5 while compiling js files using webpack.mix webpack.config.js 和 Webpack.mix.js 有什么区别? - What is the difference between webpack.config.js And Webpack.mix.js? 尝试使用 Laravel mix / webpack 时出现 JS 错误 - JS errors when trying to use Laravel mix / webpack 为什么我的 SCSS 无法加载,即使它位于我使用 React.js 搭建的 Laravel 项目中的 webpack.mix.js 中? - Why won't my SCSS load even though it's in the webpack.mix.js in my Laravel project that's scaffolded with React.js? 在Laravel mix中编译和初始化外部JS库 - Compiling and initializing external JS library in Laravel mix Laravel,webpack.mix中的js,未找到功能 - Laravel, js in webpack.mix, function not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM