14

我收到了这个错误:

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):
  • 导轨 5.1.4

  • 链轮(4.0.0.beta5、4.0.0.beta4、3.7.1)

  • 链轮导轨(3.2.1、3.2.0、2.3.3)

清单.js

//= link_tree ../images

//= link_directory ../javascripts .js

//= link_directory ../stylesheets .css

资产.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 )

应用程序.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"
4

1 回答 1

1

application.css将重命名为后也得到了这个application.scss

修复很简单,只需让 manifest.js 文件看起来像这样:

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

重新启动服务器,希望可以修复它。祝你好运。

于 2020-05-04T07:59:08.220 回答