Custom startup command for Node.js app on Azure with Babel 6

后端 未结 1 587
太阳男子
太阳男子 2020-12-12 06:55

I\'m having the same issue as this question which wasn\'t really resolved as the original questioner abandoned this route. I\'m trying to run a node app on Azure using Babel

相关标签:
1条回答
  • 2020-12-12 07:14

    It seems that to run node.js applications in ES2015 on Web Apps. We need to compile them to ES5 version, you can leverage Custom Deployment Script to achieve this.

    Here is example repos on GitHub, which leverages gulp and custom deployment script to compile the node.js from ES6 to ES5 via the Azure deployment task.

    Specially, this example defines several scripts in package.json for the deployment task calling:

    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "gulp nodemon",
        "build": "gulp build"
      },
    

    And manually call the npm scripts in deploy.cmd before KuduSync task move the deployment folder to production folder.

    :Deployment
    echo Handling node.js deployment.
    
    :: 0. Select node version for build
    call :SelectNodeVersion
    
    :: 1. Install build dependencies
    pushd "%DEPLOYMENT_SOURCE%"
    call :ExecuteCmd !NPM_CMD! install --production
    IF !ERRORLEVEL! NEQ 0 goto error
    popd
    
    :: 2. Run build command
    pushd "%DEPLOYMENT_SOURCE%"
    call :ExecuteCmd !NPM_CMD! run-script build
    IF !ERRORLEVEL! NEQ 0 goto error
    popd
    
    0 讨论(0)
提交回复
热议问题