简体   繁体   English

为什么预编译资产不再起作用?

[英]Why does precompile assets no longer work?

Rails 4.2.1, Ruby 2.2.6, sprockets 3.7.1, sprockets-rails 3.2.0 Rails 4.2.1,Ruby 2.2.6,链轮3.7.1,sprockets-rails 3.2.0

I am trying to deploy to my staging server with a new .js file and the precompile did nothing. 我正在尝试使用新的.js文件部署到我的登台服务器,并且预编译没有执行任何操作。 Here is the output with '--trace'. 这是带有“ --trace”的输出。

  ** Invoke assets:precompile (first_time)
  ** Invoke assets:environment (first_time)
  ** Execute assets:environment
  ** Invoke environment (first_time)
  ** Execute environment
  ** Execute assets:precompile
  ** Invoke ckeditor:nondigest (first_time)
  ** Invoke environment 
  ** Execute ckeditor:nondigest

I have tried running rake assets:clean, assets:clobber, and assets:precompile with and without 'RAILS_ENV=staging bundle exec' prepended to those commands - nothing. 我试过运行rake asset:clean,assets:clobber和assets:precompile,在有和没有'RAILS_ENV = staging bundle exec'的情况下使用这些命令-不做任何事情。 I deleted the assets folder and ran the precompile again - nothing. 我删除了Assets文件夹,然后再次运行了预编译-什么都没有。 I have incremented the assets.version - nothing. 我增加了assets.version-什么都没有。

I tried putting my assets precompile directive in /config/initializers/assets.rb, /config/environments/staging.rb, and /config/application.rb 我尝试将资产的precompile指令放在/config/initializers/assets.rb、/config/environments/staging.rb和/config/application.rb中

 Rails.application.config.assets.version = '1.0.2'
 Rails.application.config.assets.precompile += %w(
  admin.css
  admin.js
  new_file.js
 )

Is there a way to tell what file the assets:precompile is looking in? 有没有办法告诉资产:precompile正在查看哪个文件?

* UPDATE * *更新*

Setting assets.compile = true and deploying makes the assets precompile. 设置asset.compile = true并进行部署可以使资产进行预编译。 I was under the impression that this directive would make rails serve assets on the fly instead of using the precompiled assets. 我给人的印象是,该指令将使Rails可以即时为资产提供服务,而不是使用预编译的资产。 Is this correct to do? 这是正确的吗?

 Rails.application.config.assets.compile = true

Yes setting config.assets.compile = true will kill your apps performance and lead to long page loads randomly in production. 是的,将config.assets.compile = true设置将config.assets.compile = true应用程序的性能,并导致生产中随机地进行长页面加载。 Try running "bundle exec rake assets:precompile RAILS_ENV=production" so it uses your production environment config. 尝试运行“捆绑exec rake资产:预编译RAILS_ENV = production”,以便它使用您的生产环境配置。 file. 文件。 As to your other question about where it's looking for precompiling, there is a prefix setting in the rails config. 至于您在哪里寻找预编译的其他问题,rails配置中有一个前缀设置。 you can use to state where you want precompiled assets to go. 您可以用来说明您希望将预编译资产转到何处。 Ex. 防爆。 config.assets.prefix = '/production' But the default is to your public assets folder. config.assets.prefix = '/production'但默认设置为公共资产文件夹。

Update: ( I was going to write a long post on the subject but it looks like the creator of it wrote why to avoid in great detail already and can be found at this link: 更新:(我打算就该主题写一篇长篇文章,但它的创建者似乎写了为什么要避免详细介绍,可以在以下链接中找到:

config.assets.compile=true in Rails production, why not? 在Rails生产中config.assets.compile = true,为什么不呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM