在Heroku上构建coffeescript

时间:2014-11-30 14:12:19

标签: node.js heroku coffeescript

有没有人知道如何在Heroku上构建coffeescript?

我有一个nodejs Web应用程序,带有一些客户端资源(都是用咖啡写的),并希望让heroku构建咖啡脚本,而不必在本地构建并上传目标。

我按照指示尝试了Aergonaut build pack - 但是给了我以下错误:

       /tmp/node-node-H5WL/bin/node: error while loading shared libraries: libssl.so.0.9.8: cannot open shared object file: No such file or directory
 !     Failed to install --production dependencies with npm
 !     Push rejected, failed to compile Coffeescript app

的package.json:

{
  "name": "WebClient",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "express": "~4.9.0",
    "body-parser": "~1.8.1",
    "cookie-parser": "~1.3.3",
    "morgan": "~1.3.0",
    "serve-favicon": "~2.1.3",
    "debug": "~2.0.0",
    "jade": "~1.6.0",
    "coffee-script": "1.8.0"
  }
}

1 个答案:

答案 0 :(得分:0)

好的,我用gulp想出来了。 这是我的package.json

{
  "name": "SSWebClient",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www",
    "postinstall": "gulp",
    "prestart": "npm install"
  },
  "dependencies": {
    "express": "4.11.*",
    "body-parser": "1.12.*",
    "cookie-parser": "1.3.*",
    "morgan": "1.5.*",
    "serve-favicon": "2.2.*",
    "nconf": "0.7.*",
    "debug": "2.1.*",
    "underscore": "1.8.*",
    "jade": "1.9.*",
    "coffee-script": "1.9.*",
    "less": "2.4.*",
    "gulp": "3.8.*",
    "gulp-coffee": "2.3.*",
    "gulp-sourcemaps": "1.3.*",
    "gulp-rename": "*",
    "gulp-less": "*",
    "gulp-load-plugins": "*",
    "gulp-develop-server": "*",
    "gulp-livereload": "3.7.*",
    "gulp-cached": "*",
    "del": "*"
  }
}

你的gulpfile(在我的情况下是coffeescript)如下。为了兴趣,我还包括了LESS配置。我还包括gulp-load-plugins,使代码更简洁。 注意:您需要Heroku的阶段任务。

gulp = require 'gulp'
plugins = require('gulp-load-plugins')()

compileCoffee = ->
  gulp.src './src/**/*.coffee'
  .pipe plugins.cached 'compileCoffee'
  .pipe plugins.sourcemaps.init()
  .pipe plugins.coffee()
  .pipe plugins.sourcemaps.write()
  .on 'error', (err) -> console.log err.toString()
  .pipe gulp.dest './target'

compileLess = ->
  gulp.src './src/client/**/*.less'
  .pipe plugins.cached 'compileLess'
  .pipe plugins.less()
  .on 'error', (err) -> console.log err.toString()
  .pipe gulp.dest './target/client'

gulp.task 'build', ['compileCoffee', 'compileLess']

gulp.task 'stage', ['build']