On Thu, Sep 19, 2013 at 12:24 PM, C. Scott Ananian
<canan...@wikimedia.org>wrote:

>
> - The interaction between ResourceLoader and @import seems a bit
> under-defined.  [...] It would be nice to have a
> concrete written guideline for how MW authors are expected to use @import
> and/or better integrate @import with ResourceLoader.
>
> - @import processes referenced URLs asynchronously, IIRC, which might cause
> issues w/ integration.  I haven't done a code review to see how the
> existing patches handle this (or not).
>

@import directives in LESS files pointing at other LESS files are processed
synchronously by phpless and are not present in the generated CSS output,
and that's the only use of '@import' we encourage / allow.

@import is reserved for loading mix-ins and variables so that they may be
used by the current LESS stylesheet. It is not intended to be used for
concatenating / bundling stylesheets that are related to one another only
conceptually; that's what the ResourceLoader module definition is for.


/* ------------- Valid use of @import: ------------- */

# myExtension.less
@import "extensionColors.less";
body { background-color: @bgColor; }

# extensionColors.less
@bgColor: #ccc;


/* ------------- Invalid use of @import: ------------- */

# myExtension.less
@import "headerStyles.less";
body { background-color: #ccc; }

# headerStyles.less
h1 { font-family: serif; }

The relatedness of myExtension.less / headerStyles.less in the second
example should be expressed by referencing these files in the 'styles'
array of the same ResourceLoader module.

I can commit to documenting this on mw.org if / when the proposal is
accepted and the patch is merged.
_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to