Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asset application.css is not declared but it is declared in manifest

I got this error:

ActionView::Template::Error (Asset `application.css` was not declared to be precompiled in production.
Declare links to your assets in `app/assets/config/manifest.js`.

  //= link application.css
and restart your server):
  • Rails 5.1.4

  • sprockets (4.0.0.beta5, 4.0.0.beta4, 3.7.1)

  • sprockets-rails (3.2.1, 3.2.0, 2.3.3)

Manifest.js

//= link_tree ../images

//= link_directory ../javascripts .js

//= link_directory ../stylesheets .css

Assets.rb

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

Application.rb

require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "action_cable/engine"
require "sprockets/railtie"
require "rails/test_unit/railtie"
like image 463
Mehmet Kemal Bayer Avatar asked Sep 24 '17 14:09

Mehmet Kemal Bayer


1 Answers

Got this too after changing renaming application.css to application.scss.

The fix is easy enough, just make your manifest.js file look like this:

//= link_tree ../images
//= link application.css

Restart the server and hopefully that will fix it. Good luck.

like image 180
stephenmurdoch Avatar answered Oct 27 '22 21:10

stephenmurdoch