I use the following command to bundle my scripts via the Laravel Mix module:
npm run dev // Compile scripts.
npm run prod // Compile and minify scripts.
Are these native npm commands or custom Laravel Mix commands? Where are they defined?
I noticed they are listed as "scripts" in the Laravel package.json. What exactly are these scripts, custom commands for Webpack via Laravel Mix?
"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 --disable-host-check --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"
},
They are indeed the scripts as defined in the package.json
file as you discovered. The values are run by your shell (so, for example, bash
, zsh
, etc. on UNIX-like operating systems).
One key thing to note is that the node_modules/.bin
directory is added to PATH
before executing. So, in the case of the two scripts you're asking about, cross-env
can be found in node_modules/.bin
(because it's almost certainly specified as a devDependency elsewhere in the package.json
) as long as you've already run npm install
or npm ci
within the project directory.