Heroku rake assets:precompile don run build:css - "application.css" 在资产管道中不存在



我正在将Rails 6应用程序迁移到Rails 7。

当我push到heroku时,我在资产预编译时没有错误

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        Asset precompilation completed (3.90s)
remote:        Cleaning assets
remote:        Running: rake assets:clean

但是当我打开网站时,我得到

ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.

这很奇怪,因为heroku应该运行npm run build:css

package.json

"scripts": {
"build": "node esbuild.config.js",
"build:css": "sass ./app/assets/stylesheets/application.sass.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
}

即使我有多个buildpacks

$ heroku buildpacks
=== Buildpack URLs
1. heroku/nodejs
2. heroku/ruby

如果我用

检查构建
heroku run bash
cd /app/assets/builds 
ls

包含

application.js

如果尝试使用config.assets.compile = true

,我会得到相同的错误应用程序/资产/样式表/application.sass.scss

@charset "UTF-8";
@import "metronic/css/pages/invoices/invoice-2";
@import "metronic/css/pages/login/login-3";
@import "metronic/css/pages/wizard/wizard-1";
@import "metronic/css/style.bundle";
@import "direct_upload";
@import "toastr/toastr"; 
@import "daterangepicker/daterangepicker";
@import "bootstrap-multiselect/dist/css/bootstrap-multiselect";
@import "custom/custom";
@import "custom/dropdown";

SOLVED

重命名从

app/assets/stylesheets/application.saas.scss

app/assets/stylesheets/application.scss

和更新后的package.json

"build:css": "sass ./app/assets/stylesheets/application.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"

相关内容

  • 没有找到相关文章

最新更新