Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge theme config files #272

Open
jeremyharris opened this issue Jun 12, 2015 · 2 comments
Open

Merge theme config files #272

jeremyharris opened this issue Jun 12, 2015 · 2 comments

Comments

@jeremyharris
Copy link
Contributor

Problem

There doesn't seem to be a way to merge multiple ini config files into a single file that is used to build. A feature like this would be useful specifically for merging theme config into an application's build config. This would be useful with CMS type applications (i.e., Croogo) that use CakePHP theming.

Bare bones example

Here's a real world example of what I'd like to do.

Config/asset_compress.ini

[css]
paths[] = WEBROOT/css/
cachePath = WEBROOT/asset_cache

[styles.css]
files[] = normalize.css
files[] = bootstrap.css
files[] = base.css

View/Themed/SomeTheme/Config/asset_compress.ini

[styles.css]
files[] = styles.css
files[] = navigation.css

The desired result here would be that the configuration would be merged and the final configuration would look something like this:

[css]
paths[] = WEBROOT/css/
cachePath = WEBROOT/asset_cache

[styles.css]
theme = true
files[] = normalize.css
files[] = bootstrap.css
files[] = base.css
files[] = theme:css/styles.css
files[] = theme:css/navigation.css

Decoupling

Splitting ini config files like this would decouple the application's config from the defined themes, whereas a current solution might be to use theme:css/navigation.css couples the application config to the existence of that css file in the theme.

Merging

Since a Theme isn't a standalone package, like a Plugin would be, an incomplete ini file like the one above doesn't seem like a problem. Themes seem like they would be application-aware, so bringing in application config like cachePath also doesn't feel wrong.

RFC

I'd like to hear ideas of how this should be accomplished so I can submit a PR, or if there's anything wrong with what I'm proposing. I'm thinking all that might need to be done is merging (and prepending theme: to files) it during AssetConfig::buildFromIniFile. Perhaps requiring a new mergeThemeConfig option to the [General] section should be added for this functionality.

I'm not super aware of the internals of AssetCompress so there are probably things I'm missing here.

@markstory
Copy link
Owner

How would AssetCompress know which themes to scan/build?

Should theme files ve able to define new filters/override filters? Or only define new targets?

@jeremyharris
Copy link
Contributor Author

Good questions. Perhaps it can create a merged build for each theme, prefixing the build file and serving the theme build if a theme is active when the helper tries to serve it. This would allow runtime themes to still have complete builds.

I don't think theme configs should do anything but add files to builds. The application is responsible for filters in the same way the application is responsible for actually building the assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants