Closed ianroberts closed 1 year ago
Demo application available at https://github.com/ianroberts/cross-plugin-assets
assets {
minifyJs = true
minifyCss = true
configOptions = [
commonJs: false,
bable: false
// babel: [enabled: false, processJsFiles: false]
// https://github.com/errbuddy/babel-asset-pipeline
] //useful for custom config on extension libraries
excludes = ['**/*esm*']
packagePlugin = true
}
Do you have the packagePlugin = true
?
Do you have the
packagePlugin = true
?
I did not, and I can confirm that adding this to the plugins' build.gradle
files does indeed fix the problem. So I guess I can close this issue and instead open one against grails-forge asking why this option is not enabled in the default build.gradle
for a plugin project on https://start.grails.org...
I spoke too soon, looks like this issue has already been identified and fixed in grails-forge (https://github.com/grails/grails-forge/issues/197), it's just not live on the https://start.grails.org deployment yet.
Set-up
I have a somewhat complex project layout with multiple layers of Grails plugins - the "core" of my app is one plugin, the "skin" is a second plugin that depends on the core one, then the actual Grails app depends on both the core and skin plugins and adds tenant-specific logic. The exact app is not important, the essential part is the dependencies
The skin plugin provides the layout that all GSPs depend on, providing some CSS and JS of its own but also depending on common CSS and JS from the core plugin.
require
-s bootstrap, jQuery, etc.)*= require core.css
<asset:stylesheet src="skin.css" />
<meta name="layout" content="main">
Expected behaviour
In both
bootRun
andassetCompile
, any page referencing themain.gsp
layout gets bothcore.css
from the core plugin andskin.css
from the skin plugin.Actual behaviour
bootRun
andassetCompile
(whether called directly or as a dependency ofassemble
) gives a warningand the core CSS is not available in the rendered page.
Observations
Note that if I build a WAR and look inside it, the
core.css
has been minified and hashed inside the core plugin JAR file inWEB-INF/lib
, but it was not found when building assets for the intermediate skin plugin.Also I can refer to
core.css
directly from the main app (by putting<asset:stylesheet src="core.css"/>
inindex.gsp
) and it loads correctly. So the app is able to reference assets from any of its plugins, but a plugin is not able to reference assets from a different plugin.Is this a bug or is the behaviour by design? Is one plugin supposed to be able to depend on another plugin and include its assets? I assumed so but it's not actually stated explicitly in the documentation that plugins can use assets from plugins, only that plugins can provide assets to the app.