将 gulp 项目部署到 azurewebsites
Deploy gulp project to azurewebsites
我的项目看起来像这样:
├── bower.json
├── 源码
│ ├── bower_components
│ ├── 图片
│ ├── index.html
│ ├── scripts.min.js
│ └── styles.min.css
├── gulpfile.js
├── index.html
├── node_modules
│ ├── gulp-module-1
│ └── gulp-module-2
├── package.json
└── README
我通过 'gulp serve' 在本地主机上构建它。如何在 ftp 服务器 (azurewebsites) 上托管?要上传什么?
请先看评论!以下答案仅适用于您的 gulp serve
仅用于编译脚本的情况。如果您的 gulp 正在启动网络服务器,则无需尝试以下操作。
Azure Web 应用程序(又名 Azure 网站)由 Kudu 提供支持。
您可以通过将 .deployment
和 deployment.sh
添加到项目的根目录来在 Kudu 中设置自定义部署脚本。每次当您将新提交推送到存储库时,Kudu 都会 运行 您的部署脚本。 (注意:FTP上传不会触发部署)
样本.deployment
:
[config]
command = bash ./deploy.sh
示例 deploy.sh
(下面博客 post 的修改版本)
# 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
我的项目看起来像这样:
├── bower.json
├── 源码
│ ├── bower_components
│ ├── 图片
│ ├── index.html
│ ├── scripts.min.js
│ └── styles.min.css
├── gulpfile.js
├── index.html
├── node_modules
│ ├── gulp-module-1
│ └── gulp-module-2
├── package.json
└── README
我通过 'gulp serve' 在本地主机上构建它。如何在 ftp 服务器 (azurewebsites) 上托管?要上传什么?
请先看评论!以下答案仅适用于您的 gulp serve
仅用于编译脚本的情况。如果您的 gulp 正在启动网络服务器,则无需尝试以下操作。
Azure Web 应用程序(又名 Azure 网站)由 Kudu 提供支持。
您可以通过将 .deployment
和 deployment.sh
添加到项目的根目录来在 Kudu 中设置自定义部署脚本。每次当您将新提交推送到存储库时,Kudu 都会 运行 您的部署脚本。 (注意:FTP上传不会触发部署)
样本.deployment
:
[config]
command = bash ./deploy.sh
示例 deploy.sh
(下面博客 post 的修改版本)
# 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