如何将使用 Gulp 的节点部署到 heroku [英] How to deploy node that uses Gulp to heroku

查看:28
本文介绍了如何将使用 Gulp 的节点部署到 heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gulp 和 gulp 插件,如 gulp-minify-css、gulp-uglify 等(列为我的应用程序的 npm 依赖项).

I'm using gulp and also gulp plugins like gulp-minify-css, gulp-uglify etc (that listed as npm dependencies for my application).

我也不提交 npm_modules 文件夹和 public 文件夹,所有生成的文件都在那里.在部署和设置我的服务器(它已经在寻找公共文件夹)之后,我无法弄清楚如何构建我的应用程序(我有 gulp build 命令).

Also I don't commit npm_modules folder and public folder, where all generated files are. And I can't figure out how to build my app (I have gulp build command) after deploy and setup my server (it's already looking for public folder).

在上传之前提交似乎是个坏主意.也许有一些温和的决定......有什么想法吗?

It seems me a bad idea to commit before upload. Maybe there are some gentle decisions... Any thoughts?

分叉自:如何部署节点应用程序使用 grunt 到 heroku

推荐答案

通过将其添加到我的package.json"文件中,我能够使其工作:

I was able to get this to work by adding this into my "package.json" file:

"scripts": {
  "start": "node app",
  "postinstall": "gulp default"
}

postinstall 脚本在构建包之后运行.查看这个了解更多信息.唯一令人讨厌的是,您的所有依赖项都必须存在于依赖项"下,而不是拥有单独的devDependencies"

The postinstall script is run after the build pack. Check this for more information. The only annoying thing is that all of your dependencies have to live under "dependencies" instead of having separate "devDependencies"

我不需要对构建包或配置做任何其他事情.这似乎是最简单的方法.

I didn't need to do anything else with buildpacks or configuration. This seems like the simplest way to do it.

我在这里

这篇关于如何将使用 Gulp 的节点部署到 heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆