How to deploy node that uses Gulp to heroku

后端 未结 8 1267
遥遥无期
遥遥无期 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:20

    How to deploy to Heroku (or Azure) with git-push

    // gulpfile.js
    
    var gulp = require('gulp');
    var del = require('del');
    var push = require('git-push');
    var argv = require('minimist')(process.argv.slice(2));
    
    gulp.task('clean', del.bind(null, ['build/*', '!build/.git'], {dot: true}));
    
    gulp.task('build', ['clean'], function() {
      // TODO: Build website from source files into the `./build` folder
    });
    
    gulp.task('deploy', function(cb) {
      var remote = argv.production ?
        {name: 'production', url: 'https://github.com//site.com', branch: 'gh-pages'},
        {name: 'test', url: 'https://github.com//test.site.com', branch: 'gh-pages'};
      push('./build', remote, cb);
    });
    

    Then

    $ gulp build --release
    $ gulp deploy --production
    

    See also

    • https://github.com/koistya/git-push
    • https://github.com/kriasoft/react-starter-kit (tools/deploy.js)

提交回复
热议问题