推送到heroku时预编译资产失败

时间:2019-09-01 05:24:26

标签: ruby-on-rails heroku asset-pipeline assets precompile

我知道我之前在StackOverflow上已经看到过这个问题,但是似乎没有人在与我相同的地方失败,因此答案无法解决我的问题。

我想知道是否有人可以帮助我弄清楚为什么我的资产没有进行预编译。

这是我遇到的错误:

    remote:        Running: rake assets:precompile
    remote:        yarn install v1.16.0
    remote:        [1/4] Resolving packages...
    remote:        [2/4] Fetching packages...
    remote:        info fsevents@1.2.9: The platform "linux" is incompatible with this module.
    remote:        info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
    remote:        [3/4] Linking dependencies...
    remote:        warning " > webpack-dev-server@3.8.0" has unmet peer dependency "webpack@^4.0.0".
    remote:        warning "webpack-dev-server > webpack-dev-middleware@3.7.0" has unmet peer dependency "webpack@^4.0.0".
    remote:        [4/4] Building fresh packages...
    remote:        success Saved lockfile.
    remote:        Done in 21.32s.
    remote:        I, [2019-09-01T05:06:40.485901 #264]  INFO -- : Writing /tmp/build_dc3bc682403746c3883d47bc4513d23d/public/assets/faces-d9e713d207750f54b653abca86f1588e6124d1071d7c70873c37a90f3efd8c32.png
    remote:        I, [2019-09-01T05:06:41.455771 #264]  INFO -- : Writing /tmp/build_dc3bc682403746c3883d47bc4513d23d/public/assets/application-27ec74fcb0880a8202ea94076e3a1c791a71d3acadb56e4d5a3de8d75e89e4cf.js
    remote:        I, [2019-09-01T05:06:41.456654 #264]  INFO -- : Writing /tmp/build_dc3bc682403746c3883d47bc4513d23d/public/assets/application-27ec74fcb0880a8202ea94076e3a1c791a71d3acadb56e4d5a3de8d75e89e4cf.js.gz
    remote:        Aborted
    remote: 
    remote:  !
    remote:  !     Precompiling assets failed.
    remote:  !
    remote:  !     Push rejected, failed to compile Ruby app.
    remote: 
    remote:  !     Push failed
    remote: Verifying deploy...
    remote: 
    remote: !   Push rejected to iwell.
    remote: 
    To https://git.heroku.com/iwell.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/iwell.git'

如果我在本地预编译资产,然后在推送后破坏它们,则可以解决此问题。但这不是部署项目的非常可维护的方法。

我尝试从管道中删除任何不必要的资产,而我们的JS文件中几乎没有内容:

在app / javascript / packs / application.js中:

    ```import 'bootstrap';
    import "../plugins/flatpickr";
```    

在app / javascript / plugins / flatpickr.js中:

```flatpickr(".datepicker", {
  altInput: true,
  enableTime: true,
  dateFormat: "Y-m-d H:i",
  time_24hr: true,
  minDate: "today",
  maxDate: new Date().fp_incr(60),
});```

根据错误,它现在无法通过,但我确实看不到问题!

0 个答案:

没有答案