我的项目看起来像这样:
├──bower.json
├──src
│├──bower_components
│├──图像
│├──index.html
│├──tcripts.min.js
│└──styles.min.css
├──gulpfile.js
├──index.html
├──node_modules
│├──gulp-module-1
│└──gulp-module-2
├──package.json
└──自述文件
我通过' gulp serve'在localhost上构建它。我如何在ftp服务器(azurewebsites)上托管?要上传什么?
答案 0 :(得分:3)
请先查看评论!以下答案仅适用于您的gulp serve
仅用于编译脚本的情况。如果您的gulp正在启动Web服务器,则无需在下面尝试。
Azure Web App(又名Azure网站)由Kudu支持。
您可以在Kudu中设置自定义部署脚本,方法是在项目的根目录中添加.deployment
和deployment.sh
。每次将新提交推送到存储库时,Kudu都会运行您的部署脚本。 ( 注意 :FTP上传不会触发部署)
示例.deployment
:
[config]
command = bash ./deploy.sh
示例deploy.sh
(以下博文中的修改版)
# Deployment
# ----------
echo Handling node.js gulp deployment.
# 1. Select node version
selectNodeVersion
# 2. Install npm packages
if [ -e "$DEPLOYMENT_SOURCE/package.json" ]; then
eval $NPM_CMD install
exitWithMessageOnError "npm failed"
fi
# 3. Install bower packages
if [ -e "$DEPLOYMENT_SOURCE/bower.json" ]; then
eval $NPM_CMD install bower
exitWithMessageOnError "installing bower failed"
./node_modules/.bin/bower install
exitWithMessageOnError "bower failed"
fi
# 4. Run gulp for build
if [ -e "$DEPLOYMENT_SOURCE/gulpfile.js" ]; then
eval $NPM_CMD install gulp
exitWithMessageOnError "installing gulpfailed"
./node_modules/.bin/gulp serve
exitWithMessageOnError "gulp failed"
fi
# 5. KuduSync to Target
"$KUDU_SYNC_CMD" -v 500 -f "$DEPLOYMENT_SOURCE/dist" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
exitWithMessageOnError "Kudu Sync to Target failed"
进一步阅读:
Git and Grunt Deploy to Windows Azure
Custom Deployment Scripts For Microsoft Azure Web App (Website) Using Git Deployment