Home > Mobile >  Heroku rake assets:precompile don't run build:css - "application.css" is not present
Heroku rake assets:precompile don't run build:css - "application.css" is not present

Time:07-07

I am migrating a Rail 6 app to Rails 7.

When I push to heroku I get not error during asset precompile

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

but when I open the website I get

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

This is strange because heroku should run 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"
  }

even if I have multiple buildpacks

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

If I inspect the build with

heroku run bash
cd /app/assets/builds 
ls

it only contains

application.js

I get the same error if trying with config.assets.compile = true

app/assets/stylesheets/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";

CodePudding user response:

SOLVED

Renamed

From

app/assets/stylesheets/application.saas.scss

to

app/assets/stylesheets/application.scss

and updated package.json

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