How to deploy node that uses Gulp to heroku

后端 未结 8 1236
遥遥无期
遥遥无期 2020-12-07 16:21

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

Also I don\'t commit npm_modules fo

相关标签:
8条回答
  • 2020-12-07 17:24

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

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

    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.

    I wrote about the process I used here

    0 讨论(0)
  • 2020-12-07 17:24

    There's a specific startup script that Heroku provides;

    "scripts": {
      "start": "nodemon app.js",
      "heroku-postbuild": "gulp"
    }
    

    note that in your gulpfile.js (gulpfile.babel.js if you es6-ifed your gulp build process), you should have a task name default which will be automatically run after the dependencies are installed via Heroku.

    https://devcenter.heroku.com/articles/nodejs-support#heroku-specific-build-steps

    0 讨论(0)
提交回复
热议问题