javascript / packs中的所有js文件未在生产环境中加载到我的应用程序中

时间:2019-05-30 21:49:06

标签: ruby-on-rails webpack stimulusjs

该应用程序运行正常。带有StimulusJS的Rails 5.1。

我试图在服务器上做

RAILS_ENV=production bundle exec rake assets:precompile

无效。

似乎不可访问

这是 production.rb

中的相关代码
Rails.application.configure do
  # Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false

  # Settings specified here will take precedence over those in config/application.rb.
  # Analytics account
  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = true

和显示错误的控制台屏幕

browser console log

1 个答案:

答案 0 :(得分:0)

鉴于“正常”管道中的资产正在运行,并且在尝试了语法变化之后,最终有效的方法是通过服务器中的ssh获取并运行以下命令:

RAILS_ENV=production bundle exec rails webpacker:compile

似乎普通资产和webpacker采取两种不同的方式。