Options
All
  • Public
  • Public/Protected
  • All
Menu

This factory ensures that instances of a block are re-used when blocks are going to be compiled/optimized together. Multiple instances of the same block will result in analysis and optimization bugs.

This also ensures that importers and preprocessors are correctly used when loading a block file.

Hierarchy

  • BlockFactory

Index

Constructors

constructor

Properties

blockNames

blockNames: ObjectDictionary<number>

Private blocks

blocks: ObjectDictionary<Block>

configuration

configuration: ResolvedConfiguration

importer

importer: Importer

parser

parser: BlockParser

Private paths

paths: ObjectDictionary<string>

postcssImpl

postcssImpl: postcss

Private preprocessQueue

preprocessors

preprocessors: Preprocessors

Private promises

promises: ObjectDictionary<Promise<Block>>

Methods

_getBlockPromise

getBlock

getBlockFromPath

  • getBlockFromPath(filePath: string): Promise<Block>

getBlockRelative

getUniqueBlockName

  • getUniqueBlockName(name: string): string
  • Register a new block name with the BlockFactory. Return true true if successful, false if already exists.

    Parameters

    • name: string

      The new block name to register.

    Returns string

    True or false depending on success status.

parse

  • parse(root: Root, identifier: string, name: string): Promise<Block>
  • Parse a postcss.Root into a Block object. Save the Block promise and return it.

    Parameters

    • root: Root

      The postcss.Root to parse.

    • identifier: string

      A unique identifier for this Block file.

    • name: string

      Default name for the block.

    Returns Promise<Block>

    The Block object promise.

prepareForExit

  • prepareForExit(): Promise<void>
  • In some cases (like when using preprocessors with native bindings), it may be necessary to wait until the block factory has completed current asynchronous work before exiting. Calling this method stops new pending work from being performed and returns a promise that resolves when it is safe to exit.

    Returns Promise<void>

preprocessor

reset

  • reset(): void

Generated using TypeDoc