【问题标题】:Grails resources not working with cache-busting CKEditor release (4.5.5+)Grails 资源不适用于缓存清除 CKEditor 版本 (4.5.5+)
【发布时间】:2016-06-23 05:39:37
【问题描述】:

我无法使用资源插件获取 Grails 2.5.2 应用程序来处理 cache-busting change made to CKEditor。资源插件配置如下:

grails.resources.adhoc.patterns = ['/js/*', '/images/*', '/css/*', '/plugins/*', '/thirdparty/*', '/templates/*']
grails.resources.adhoc.includes = ['/js/**', '/images/**', '/css/**', '/plugins/**', '/thirdparty/**', '/templates/**']

CKEditor 代码位于app-dir/web-app/thirdparty/ckeditor 下,当前版本为 4.5.9。缓存清除更改是在 4.5.5 中进行的,4.5.4 版与 grails resources 完美配合。

使用 4.5.9 运行应用程序时,我在控制台中收到以下错误:

GET resource:/thirdparty/ckeditor/skins/moono/icons.png?t=a35abfe net::ERR_UNKNOWN_URL_SCHEME

resources 插件似乎不能很好地处理 ckeditor 的 editor.css 文件中的值(应用程序提供的文件指向 app-dir/thirdparty/ckeditor/skins/moono/editor.css?t=G4CDhttp://localhost:8080/app-dir/static/thirdparty/ckeditor/skins/moono/editor.css?t=G4CD)。如果我直接查看这个文件,它包含以下图标.png 和icons_hidpi.png 文件,表明resources 插件错误地将图像文件链接(实际上除了第一个之外)替换为“资源: /..." 不需要存在的 url,因此会出现控制台错误。奇怪的是,只有带有 t 参数的icons.png 和icons_hidpi.png 文件会以这种方式更改,同一editor.css 文件中的其他图像文件将被单独保留。

.cke_button__bold_icon {background: url(icons.png?t=a35abfe) no-repeat 0 -0px !important;}
.cke_button__italic_icon {background: url(resource:/thirdparty/ckeditor/skins/moono/icons.png?t=a35abfe) no-repeat 0 -24px !important;}
.cke_button__strike_icon {background: url(resource:/thirdparty/ckeditor/skins/moono/icons.png?t=a35abfe) no-repeat 0 -48px !important;}
.cke_button__subscript_icon {background: url(resource:/thirdparty/ckeditor/skins/moono/icons.png?t=a35abfe) no-repeat 0 -72px !important;}

如果我添加以下配置,应用程序运行并显示完美。

grails.resources.processing.enabled = false

如果我使用

grails.resources.mappers.cssrewriter.excludes = ['/thirdparty/ckeditor/skins/moono/**']

为了防止 resources 修改 ckeditor's editor.css 文件,似乎没有任何改变。

我能做什么?我不能在 4.5.4 离开 ckeditor,因为我正在尝试修复与它的交互。我已经在使用相同的配置as recommended in another post,但这并不能解决问题。 Disabling css rewriting altogether 只是破坏了其他插件。

【问题讨论】:

    标签: grails ckeditor grails-resources-plugin


    【解决方案1】:

    最终的解决方案(由同事推荐)是排除特定的 CSS 文件被 grails resources 处理:

    resource url:"thirdparty/ckeditor/skins/moono/editor.css", exclude: "*"
    

    这样可以避免影响其他不受升级的 CKEditor 影响或受益于grails resources 处理的文件。

    【讨论】:

    • 在尝试了很多其他建议的解决方案之后,只有这个对我有用(同样的问题,但使用 Font Awesome 和 Grails 2.5.5)。谢谢!
    猜你喜欢
    • 2010-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-25
    • 2014-09-09
    • 2012-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多