This is the dev preview website. Check out the document at lynxjs.org

Home > @lynx-js/template-webpack-plugin > LynxTemplatePlugin > convertCSSChunksToMap

LynxTemplatePlugin.convertCSSChunksToMap() method

Convert the css chunks to css map.

Signature:

static convertCSSChunksToMap(cssChunks: Array<string | {
        content: string;
    }>, plugins: CSS.Plugin[], enableCSSSelector: boolean): {
        cssMap: Record<string, CSS.LynxStyleNode[]>;
        cssSource: Record<string, string>;
    };

Parameters

Parameter

Type

Description

cssChunks

Array<string | { content: string; }>

The CSS chunks content.

plugins

CSS.Plugin[]

enableCSSSelector

boolean

Returns:

{ cssMap: Record<string, CSS.LynxStyleNode[]>; cssSource: Record<string, string>; }

The CSS map and css source.

Remarks

This helper currently forwards to cssChunksToMap.

The returned cssSource is keyed by cssId and uses the synthetic filename format /cssId/<id>.css.

This helper does not remap generated loc fields to original source coordinates.

Example

(console.log(await convertCSSChunksToMap(
  '.red { color: red; }',
  {
    targetSdkVersion: '3.2',
    enableCSSSelector: true,
  },
)));