Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm npm scripts: ng build --prod

I'm wanting to run ng build --prod with WebStorm, however it only seems to do ng build and misses the --prod command.

I'm wanting to run this in WebStorm, not in the terminal.

npm build scripts

Note: if I add --prod to Arguments, it doesn't work:

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run build --scripts-prepend-node-path=auto --prod

> [email protected] build /Users/robertking/go/src/gitlab.com/cosmoline_client
> ng build
like image 816
robert king Avatar asked Jul 01 '18 23:07

robert king


People also ask

How do I show npm scripts in WebStorm?

Press Shift twice to open the search window, start typing your query, for example, npm scripts , and select Show npm scripts from the list. Alternatively, select View | Tool Windows | npm from the main menu.

What does ng build -- prod does?

The ng build command is intentionally for building the apps and deploying the build artifacts. The command does not generate an output folder. The output folder is – dist/. The ng serve builds artifacts from memory instead for a faster development experience.

How do I run npm in WebStorm?

Type npm run or yarn run in the search field. As you type, WebStorm shows the matching scripts. Select the required one from the list and press Enter . To view the command output in the Run tool window, press Ctrl+Enter , to show the output in the Debug tool window, press Shift+Enter .

What does npm Run script build do?

Description. This runs an arbitrary command from a package's "scripts" object. If no "command" is provided, it will list the available scripts. run[-script] is used by the test, start, restart, and stop commands, but can be called directly, as well.


1 Answers

You could add --prod to the build script inside of the package.json. For example:

"scripts": {
  "ng": "ng",
  "start": "ng serve",
  "build": "ng build --prod",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e"
},

Or add an alternate step:

"scripts": {
  "ng": "ng",
  "start": "ng serve",
  "build": "ng build",
  "build:prod": "ng build --prod",
  "test": "ng test",
  "lint": "ng lint",
  "e2e": "ng e2e"
},

If you don't want to do it in the package.json file, since WebStorm isn't running ng directly (it's running via npm), it may not be passing the attributes.
Adding an additional -- may work (e.g. -- --prod).
Or try putting it in quotes (e.g. "--prod").

like image 169
martzcodes Avatar answered Oct 30 '22 20:10

martzcodes