Grails插件中的自定义CSS和JS [英] Custom CSS and JS in Grails plugins
问题描述
我正在构建一个Grails插件( grails-myorg.zip
),它将包含应该由我们组织中的每个Grails应用程序使用的可重用的代码/工件。这包括有助于为我们的应用提供一致的外观的自定义CSS / JS文件。
我想知道这里最好的行动是什么: p>
- 创建一个
grails-myorg-themes.zip
插件,其中包含可重用的CSS和JS文件,然后创建一个运行时插件/依赖(BuildConfig.groovy
)grails-myorg.zip
plugin;或 - 将CSS / JS文件放在主要的
grails-myorg.zip
插件中,然后使用Grails资源插件所有下游依赖项的文件。
最终唯一的要求是:
< > 每当开发人员在其应用程序的插件中包含主要的
grails-myorg.zip
插件,则自定义CSS / JS文件将可用(通过URL) 这样,他们就可以在他们的应用程序中添加CSS样式和其他JS文件 - 在这些常见文件中定义。 $ 应该使用哪个策略,为什么和什么配置?我没有看到有 grails-myorg-themes
插件的要求,如果 grails-myorg
成为grails应用程序资源的提供者。
第二个选项看起来像是一个很好的开始。如果资源改变和/或更新,插件版本控制就足够了。
什么:
$ b b
- 在插件中不需要资源插件,应用程序应该使用资源插件。如果在所有资源插件使用
grails-myorg
插件,那么应该通过使用export = false
in build config。 - 创建特定于业务的资源模块,可以毫不费力地在应用程序中使用。例如:
插件资源文件应该有以下内容,突出显示 dashboard
(例如,反映该品牌的企业范围模块)作为在特定页面/模板中的必需
的模块。
// MyOrgResources.groovy
modules = {
dashboard {
resource url:'js / dashboard / dashboard.js'
resource url:'css / dashboard / dashboard.css'
}
}
I am building a Grails plugin (grails-myorg.zip
) that will contain reusable code/artifacts that should be used by every Grails app in our organization. This includes custom CSS/JS files that help give our apps a consistent look-and-feel.
I'm wondering what the best course of action here is:
- Create a
grails-myorg-themes.zip
plugin, which just includes the reusable CSS and JS files, and then make that a runtime plugin/dependency (usingBuildConfig.groovy
) of the maingrails-myorg.zip
plugin; or - Put the CSS/JS files in the main
grails-myorg.zip
plugin, but then use the Grails resources plugin to configure the files for all downstream dependencies.
Ultimately the only requirement is:
Anytime a developer includes the main grails-myorg.zip
plugin as part of their app's plugins, then the custom CSS/JS files will be available (via URL) at runtime to the app's HTML files. This way, they have the option to include CSS styles and other JS stuff - defined inside these common files - in their apps.
Which strategy should I utilize, why and what would the configuration look like?
I don't see a requirement of having grails-myorg-themes
plugin if sole purpose of grails-myorg
is just to be a provider for resources to a grails app.
Second option looks like a good start for the scenario that has been laid out. If resources change and/or updated, versioning the plugin up would suffice.
What:
- You would not need resources plugin in the plugin, app should be using resources plugin. If at all resources plugin is used in
grails-myorg
plugin then it should be excluded in the package by usingexport = false
in build config. - Create business specific resources modules which can be used in the app effortlessly. For example:
Plugin resources file should have something like below, highlighting dashboard
(say, a enterprise wide module which reflects the brand) as a module which can be required
in app in specific pages/templates.
//MyOrgResources.groovy
modules = {
dashboard {
resource url: 'js/dashboard/dashboard.js'
resource url: 'css/dashboard/dashboard.css'
}
}
So on and so forth for common domain specific resources.
Why:
The plugin is self explanatory in mentioning that "any enterprise level resource, related to a domain or a module" can be referred from this plugin. In the end, it will be a useful idea only if the plugin is documented and shared appropriately across teams, so that no one re-invents the wheel.
这篇关于Grails插件中的自定义CSS和JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!