【问题标题】:Rails 6 and Tailwind CSS does not deploy to HerokuRails 6 和 Tailwind CSS 没有部署到 Heroku
【发布时间】:2020-05-06 22:29:46
【问题描述】:

我有一个成功部署到 Heroku 并在 localhost:3000 上运行的 Rails 6 应用程序。

我通过 yarn 和 webpack 添加了 tailwindcss。它在 localhost 上运行得很好,但不能在 heroku 上运行。当我运行heroku logs 时出现以下错误

我已阅读所有 Heroku Rails 6 Webpacker 问题,并尝试了所有建议。没有任何效果。

  1. 我已经注释掉了<%= stylesheet_pack_tag %> ...没有帮助
  2. 我在 webpacker.yml 文件中切换了extract_css: true .... 没有帮助
  3. 我跑了
    • heroku buildpacks:clear
    • heroku buildpacks:set heroku/nodejs
    • heroku buildpacks:add heroku/ruby ...没有帮助

有人知道发生了什么吗?

我的 github 仓库是https://github.com/HundredBillion/enneagram

【问题讨论】:

  • 你能在哪里修复它?
  • 否 - 最终创建了一个 bootstrap rails 项目并将其推送到 Heroku。

标签: heroku yarnpkg ruby-on-rails-6 webpacker tailwind-css


【解决方案1】:

我有一个不同的错误,在更新/摆弄顺风之后,我的 create-react-app 无法部署(很可能是它做了什么)。

我的 buildpack 是 node.js。根据https://github.com/mars/create-react-app-buildpack#user-content-troubleshooting更改

确认您的应用正在使用此构建包:

heroku 构建包 如果它没有使用 create-react-app-buildpack,则设置它:

heroku buildpacks:set mars/create-react-app …并使用新的 buildpack 进行部署:

git commit --allow-empty -m '切换到 create-react-app-buildpack' git push heroku 大师

【讨论】:

    【解决方案2】:

    在遇到类似问题时偶然发现了这篇文章,希望这些信息将来对某人有所帮助。

    我通过将“tailwindcss”引用从 devDependencies 移动到依赖项块解决了 package.json 文件中的问题。

    {
      "name": "app_name",
      "private": true,
      "dependencies": {
        "@rails/actioncable": "^6.0.0",
        "@rails/activestorage": "^6.0.0",
        "@rails/ujs": "^6.0.0",
        "@rails/webpacker": "4.2.2",
        "jquery": "^3.5.1",
        "tailwindcss": "^1.2.0",  // <--- Now here.
        "turbolinks": "^5.2.0"
      },
      "version": "0.1.0",
      "devDependencies": {
                                        //<--- Was here.
        "webpack-dev-server": "^3.10.3"
      }
    }
    

    【讨论】:

      【解决方案3】:

      我和你有同样的问题,但我试过这个,它对我有用。

      在 config/webpacker.yml 中,必须设置 extract_css: true 默认为 false。

      【讨论】:

      • 这对我来说是个问题 - 对于所有环境,此设置必须为 true,我还需要将 &lt;%= stylesheet_pack_tag 'application' %&gt; 包含在 app/views/layouts/application.html.erb
      • @BobWhitelock 也一样。您是否还删除了默认的&lt;%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&gt; 并将media: 'all', 'data-turbolinks-track': 'reload' 添加到stylesheet_pack_tag
      【解决方案4】:

      我有一些建议给你,让我知道哪一个(如果有的话)适合你。

      在 webpacker.yml 中用于以下选项的所有实例

      check_yarn_integrity: false
      compile: true
      

      试试

      ./bin/setup
      rails webpacker:clobber
      rails webpacker:compile
      

      如果以上都不起作用,那么这些链接之一可能会有所帮助: - https://github.com/tailwindcss/discuss/issues/4#issuecomment-341918136 - https://github.com/IcaliaLabs/tailwindcss-rails

      【讨论】:

      • 感谢您提供此信息。它没有帮助,但我会继续尝试其他选择。
      • 这是产品吗?
      • @StevenAguilar - 是的,它用于生产
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-08
      • 1970-01-01
      • 1970-01-01
      • 2019-07-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多