Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

PowerShell script add '--prod' argument to build Angular CLI project

I am creating PowerShell script to automatically build Angular CLI project. When I use this command in my .ps1 file:

Start-Process -FilePath ng build -WorkingDirectory D:pathToAngularProject -Wait

it works perfectly but create not uglified javascript build. To be able to create production build I need to add '--prod' argument. But when I change example above on :

Start-Process -FilePath ng build -ArgumentList '--prod' -WorkingDirectory D:pathToAngularProject -Wait

I am getting the error: enter image description here

Does anyone have a suggestion how can I add an argument to 'ng build' command in PowerShell script?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Add build to the -argumentlist if it is an argument like:

Start-Process -FilePath ng -ArgumentList 'build', '--prod' -WorkingDirectory D:pathToAngularProject -Wait 

If it is part of the path quote it in the -path parameter because there are spaces:

Start-Process -FilePath "ng build" -ArgumentList '--prod' -WorkingDirectory D:pathToAngularProject -Wait

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...