Laravel 混合脚本不观察变化

Laravel mix scripts not watching changes

我正在使用 webpack 运行 监视正在更改的 .js 文件,但我需要为我的项目使用通配符而不是特定文件名。我目前正在使用下面的命令,它工作正常并在我 运行 npm run watch 时编译所有预期的文件,但在我直接在任何文件。我不得不停止观看并一次又一次地重新 运行 相同的命令。有什么我想念的吗?

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

mix.scripts([
    'resources/js/vendor/**/*.js',
    'resources/js/modules/**/*.js',
    'resources/js/plugins/**/*.js'
], 'public/js/site.js');

打包文件:

{
"private": true,
"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
    "autoprefixer": "^9.7.6",
    "bulma": "^0.9.0",
    "cross-env": "^5.1",
    "laravel-mix": "^4.0",
    "laravel-mix-purgecss": "^4.1.0",
    "node-sass": "^4.14.1",
    "postcss-import": "^12.0.1",
    "postcss-nested": "^4.2.1",
    "postcss-preset-env": "^6.7.0",
    "resolve-url-loader": "^3.1.0",
    "sass": "^1.26.10",
    "sass-loader": "^7.1.0",
    "tailwindcss": "^1.3.5",
    "vue-template-compiler": "^2.6.11",
    "webpack": "^4.44.1"
},
"dependencies": {}

}

编辑您的 package.json 文件 - 更改为:

"watch": "npm run development -- --watch",


为此:

"watch": "node_modules/.bin/webpack --watch --watch-poll --config=node_modules/laravel-mix/setup/webpack.config.js",