This is derived from discussion at the BADCamp 2012 Twig sprint: http://groups.drupal.org/node/265858 Please see these notes for the background.
We'd to provide a mechanism in a custom theme to disable the CSS files and JS files added by contrib modules (some sort of simple asset management). This makes overriding contrib styling easier: instead of copying an entire CSS file and then changing all the properties, we can simply exclude the file from being included in the first place and write our own CSS.
For example, a custom theme could implement the following syntax in the .info file. These are examples in order from most granular to least granular (Arguably, the latter examples may be overkill).
; Use case i.
; Use sub elements to exclude individual CSS or JS files.
assets[fivestar][base.theme.css] = FALSE
assets[fivestar][admin.theme.css] = FALSE
assets[fivestar][fivestar.js] = FALSE
; Use case ii.
; Exclude all CSS or JS files from a contrib.
assets[fivestar][css] = FALSE
assets[fivestar][js] = FALSE
; Use case iii.
; Exclude all assets (both CSS and JS files) from a contrib.
assets[fivestar] = FALSE
; Use case iv.
; By default, we'll have a whitelist policy: all assets will be included
; and we'll want to exclude them on a case-by-case basis. However, we
; could change the default so that all assets are *excluded* by default,
; and we can include them on a case-by-case basis.
; Disable all contrib CSS files by default and perhaps simply enable fivestar's CSS
assets[contrib][css] = FALSE
assets[fivestar][css] = TRUE
The syntax above is just an idea, so we'd like to clarify this. This is not just limited to contrib modules, but could also work on core assets (if the themer dares).
@todo Use issue summary template :)
Comments
Comment #1
c4rl commentedChanged the title to reflect this syntax is not for contribs, but rather more fore a custom themes where the themer wants to implement their own assets.
Comment #2
c4rl commentedHm, this seems to be a possible duplicate of #575298: Provide non-PHP way to reliably override CSS. Will postpone until I determine the best course of action.
Comment #3
sunA substantial part of this proposal duplicates that issue, yes.
However, some parts of this proposal go way beyond the existing issue, and I disagree with some of those proposals. Those should not and cannot be merged into the existing issue.
Thus, if you want to keep this issue for the proposals that are not covered over there yet, then do so and revise the summary to clarify them.
Comment #4
c4rl commented@sun Sounds good, thanks for providing some clarification with regard to potential duplication. I'll read-up on the existing work and revise this summary to fulfill things outside of existing scope.
Comment #5
mgifford@sun is there a list of what is and what is not in the other patch?
Should this be an 8.1.0 issue or a 9.0.0 issue?
Comment #6
fabianx commentedI like this proposal, but would be probably 9.x.
A more similar syntax is 8.1 material.
Comment #7
mgiffordOk #575298: Provide non-PHP way to reliably override CSS is in, so we have to figure out what more this issue can add and whether it can be done in 8.0 or not.
Comment #8
joelpittetI think what was done by moving the CSS/JS into libraries.yml in your theme achieves this. I could be wrong just triaging.
#2201089: hook_library_info() is replaced by *.libraries.yml file
Comment #9
mgifford@joelpittet - Seems like that doesn't work with Change Records. Adding link to https://www.drupal.org/node/2201089
Comment #10
joelpittetThanks, i bet I do that a bunch. Tab-addict. I do know this, thanks for fixing:)