在生产环境中覆盖后端资产 [英] Overriding backend assets in production environment

查看:100
本文介绍了在生产环境中覆盖后端资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个项目,该项目需要稍微改变Refinery的WYMEditor行为.通过使用rake refinery:override覆盖jquery.refinery.wymeditor.js并根据自己的需要对其进行编辑很容易做到这一点,在开发环境中效果很好.

I am working on a project that needs to alter Refinery's WYMEditor behavior a bit. This is easily done by overriding jquery.refinery.wymeditor.js using rake refinery:override and editing it to my own needs, which works fine in development environment.

但是,当涉及到生产时,覆盖将被忽略.也就是说,编译后的资产仅包含捆绑软件中的jquery.refinery.wymeditor.js,并且直接在该文件中编辑该文件可能会产生所需的效果,但这并不是应该这样做的方式.

However, when it comes to production, overrides are ignored. That is, the compiled asset just contains jquery.refinery.wymeditor.js from bundle, and editing that file directly there may give the desired effect, but that's just not the way it should be done.

奇怪的是,这个问题显然只有在尝试覆盖与后端相关的资产时才会显现出来.

Strange thing is, that the problem apparently manifests itself only when trying to override backend-related assets.

知道我使用的是炼油厂边缘可能会有用.

It might be useful to know that I am using refinery-edge.

任何帮助表示赞赏.

推荐答案

所以我设法击败了它.首先要提到的是,如果不输入精炼厂的源代码,这是不可能的.

So I have managed to beat it. First thing to mention is that it wouldn't be possible without poking into Refinery source code.

正如我已经在评论中所写的那样,问题是我试图覆盖未包含在资产中的资产(在我的情况下为 wymeditor/jquery.refinery.wymeditor.js )一个视图,但是在另一个资产中引用了该视图,该资源取自gem.而且由于链轮对精炼厂的覆盖率一无所知,因此它通过相对路径(即来自宝石(因此未修改))获取引用的资产.因此,同样,在我的情况下,解决方案是覆盖 refinery/wymeditor.js ,所有内容都具有吸引力.

As I have already written in the comment, the problem was that I was trying to override an asset (wymeditor/jquery.refinery.wymeditor.js in my case) that wasn't included in a view directly, but was referenced in another asset, which was taken from the gem. And since sprockets knows nothing about Refinery's overrides, it took the referenced assets by the relative path, i.e. from the gem (and hence, unmodified), too. So, again, in my case the solution was to override the refinery/wymeditor.js, and everything worked as a charm.

除了WYMEditor之外,您还需要更改任何其他后端脚本,您很有可能必须覆盖 refinery/refinery.js ,除了您自己的脚本之外,该脚本还包括所有其他后端脚本.需要修改.

Should you need to change any other backend script than WYMEditor, you will most likely have to override the refinery/refinery.js, which includes all other backend scripts, in addition to the very script you need to modify.

不过,有一个大问题.使用所有这些替代,由于某些文件将更新,而有些文件则不会,因此我进行的更新非常容易出错.可以通过覆盖所有内容来避免此问题,但这实际上意味着根本没有更新.

There is one big concern, though. With all these overrides, I have made any updates very error-prone, since some files will update, and some will not. It could have been avoided by overriding everything, but that effectively means no updates at all.

这篇关于在生产环境中覆盖后端资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆