webpack command in psake script is failing the task

71 Views Asked by At

In my psake task, the following commands:

exec { npm install --no-optional --no-shrinkwrap --no-package-lock }
exec { npm run prod-build }

with this npm script:

"prod-build": "webpack --config ./webpack.prod.js --display errors-only"

Gives the following error and fails my script:

89 char:12 +     exec { npm run prod-build } +            ~~~~~~~~~~~~~~~~~~ [<<==>>] Exception: clean-webpack-plugin: <projectdir>\Build\release\scripts\dist has been removed.

That's not an error or a failure, so I'm unsure as to why it's causing the build to fail.

When I adjust the npm run command to the following (No longer using psake's exec):

npm run prod-build
Write-Host "Run exit code: $lastexitcode"

I get the same error message and it doesn't hit the Write-Host line. When I try the following:

npm run prod-build -verbose
Write-Host "Run exit code: $lastexitcode"

I receive this error (again no exit code)"

Error: 8/15/2018 10:25:03 AM: 
At C:\workspace\vso\hop_hospiceorderportal\build\psake.ps1:92 char:5 +  npm run prod-build -verbose +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~ [<<==>>] Exception: npm info it worked if it ends with
 ok
psake.ps1 failed

When I run the npm run prod-build command directly in the console it works as expected. It seems like something with psake is throwing it off.

0

There are 0 best solutions below