预编译后缺少 Rails javascript 资产 [英] Rails javascript asset missing after precompile
问题描述
Rails 指南 说:
如果在生产中缺少预编译文件,您将得到一个Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError指示丢失文件名称的异常.
If there are missing precompiled files in production you will get an Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError exception indicating the name of the missing file(s).
我确实执行:
bundle exec rake assets:precompile
但是我没有收到任何错误,而且我的 javascript 文件在 manifest.yml 中丢失了.它也没有出现在 public/assets 中,所以问题只出现在生产中.
however I don't get any error, and my javascript file is missing in the manifest.yml. Also it's not appearing in public/assets, so the problem is only on production.
我在 application.js
//= require formalize/jquery-formalize
我错过了什么?
谢谢.
推荐答案
其实需要做两件事:
config.assets.precompile += %w( *.js *.css )
如所述这里和
config.serve_static_assets = true
用于本地生产测试时使用
for local production testing when using
rail s
当然使用
rake assets:precompile
但是在我的情况下 - 如果没有 config.assets.precompile 这将不起作用,因为清单不包含对我的 javascript 文件的任何引用.
however in my case - without config.assets.precompile this would have no effect since the manifest didn't contain any reference to my javascript file.
HTH.
这篇关于预编译后缺少 Rails javascript 资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!