Hellodan
Hellodan

Reputation: 1208

Laravel mix scripts not watching changes

Im using webpack to run a watch on .js files being changed, but I need to use wildcards instead of specific file names for my project. I'm currently using the commands below and it works fine and compiles all the expected files when I run npm run watch, but it will never run again after I make a change directly in any of the files. I have to stop watching and re-run the same command again and again. Is there something I am missing?

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

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

Package file:

{
"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": {}

}

Upvotes: 0

Views: 3026

Answers (1)

FullStackOfPancakes
FullStackOfPancakes

Reputation: 1381

Edit your package.json file - change this:

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


To this:

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

Upvotes: 5

Related Questions