question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to pass options via CLI?

See original GitHub issue
  • Laravel Mix Version: 0.12.1
  • Node Version: 8.1.4
  • NPM Version: 5.0.3
  • OS: Ubuntu 16.04

Description:

So I want to disable notifications. I can do that using mix.disableNotifications(), but that would mean I have to hardcode it in my webpack.mix.js. I don’t want that. I want to have a separate run task in package.json which has notifications disabled. So how are you supposed to set notifications=false from CLI?

Steps To Reproduce:

  • Try to figure out how to pass notifications=false from CLI
  • Fail

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
jacobmllr95commented, Aug 29, 2017

I stumbled across the same problem and found a solution that worked quite well for me:

const mix = require('laravel-mix');
const argv = require('yargs').argv;

...

if (argv.env.notifications === false) {
  mix.disableNotifications();
}

The command:

npm run development -- --env.notifications false
8reactions
ameenrosscommented, Aug 30, 2017

That’s almost the same I did: npm run prod-silent

Entry in package.json: cross-env NODE_ENV=production MIX_NOTIFICATIONS=false node_modules/webpack/bin/webpack.js --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

// webpack.mix.js

// ...
if (process.env.MIX_NOTIFICATIONS == 'false') {
    mix.disableNotifications();
}
// ...
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass options via CLI? · Issue #1086 · laravel-mix ...
You have access to a global process object, which, among other thins, has an argv property with all command line arguments. More here:...
Read more >
Parameters / Arguments - Windows CMD - SS64.com
How-to: Pass Command Line arguments (Parameters) to a Windows batch file. ... You can get the value of any argument using a %...
Read more >
Understanding Command Line Arguments and How to Use ...
Command line arguments are extra commands you can use when launching a program so that the program's functionality will change.
Read more >
Jest CLI Options
The jest command line runner has a number of useful options. You can run jest --help to view all available options. Many of...
Read more >
Command line options - AWS Documentation
In the AWS CLI, command line options are global parameters you can use to ... To pass true binary content, put the content...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found