Brunch + Heroku build `Cannot GET /`

Brunch + Heroku build `Cannot GET /`

本文关键字:Cannot GET build Heroku Brunch      更新时间:2023-09-26

我已经设法在Heroku上建立了我的Brunch。然而,我的Express up在导航到站点时显示Cannot GET /

从日志中推送:

       > preso@1.0.0 postinstall /tmp/build_13daabc0-9174-41fd-a59e-c2a894c07256
       > ./node_modules/brunch/bin/brunch build --production
       18 Jun 08:59:09 - info: compiled 21 files into 3 files, copied 23 in 5200ms
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
-----> Building runtime environment
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing... done, 11.8MB
-----> Launching... done, v7
       http://nameless-fortress-7923.herokuapp.com/ deployed to Heroku
To git@heroku.com:nameless-fortress-7923.git
 + 75f1076...9d2a80b master -> master (forced update)

包。json依赖性:

  "dependencies": {
    "express": "^4.4.3",
    "passport-http": "^0.2.2",
    "passport": "^0.2.0",
    "brunch": "^1.7.14",
    "javascript-brunch": "^1.7.1",
    "coffee-script-brunch": "^1.7.3",
    "css-brunch": "^1.7.0",
    "stylus-brunch": "^1.7.0",
    "static-jade-brunch": "^1.7.0",
    "jade-brunch": "^1.5.1",
    "uglify-js-brunch": "^1.7.7",
    "clean-css-brunch": "^1.7.1"
  },

My Express简单地提供public/(在一些认证之后),看起来像这样。

它得到构建成功,但似乎public/文件夹被Heroku删除/清除?

任何关于为什么会发生这种情况的想法将是感激的。

我从未使用过Brunch,但与其他构建工具一起,它会在构建期间创建一个dist文件夹。如果该dist文件夹包含在gitignore中,它不会被推送到Heroku。

同样的事情可能发生在你的公用文件夹

并不是一个很好的解决方案,但我的解决方法是简单地在本地编译它并将其添加到git中。

我在我的Makefile中做了一个deploy命令,看起来像这样

default: run
run:
    rm -rf public
    ./node_modules/brunch/bin/brunch w -s
deploy:
    rm -rf public/
    rm -rf build/
    ./node_modules/brunch/bin/brunch build --production
    mv public/ build/
    git add --all build/
    git commit -m "heroku deploy"
    git push heroku master --force
    git reset HEAD~1
    rm -rf build/
    heroku open