Home Reference Source
public class | source

WebpackMiddlewares

This service creates and manages middlewares for webpack server implementations.

Constructor Summary

Public Constructor
public

constructor(events: Events, targets: Targets, webpackConfiguration: WebpackConfiguration, webpackPluginInfo: WebpackPluginInfo)

Class constructor.

Member Summary

Public Members
public

A local reference for the events service.

public

A local reference for the targets service.

public

A local reference for the webpackConfiguration service.

public

A local reference for the plugin information.

Method Summary

Public Methods
public

generate(targetToBuild: string, targetToServe: string): MiddlewaresInformation

Generate the middlewares for a given target.

Public Constructors

public constructor(events: Events, targets: Targets, webpackConfiguration: WebpackConfiguration, webpackPluginInfo: WebpackPluginInfo) source

Class constructor.

Params:

NameTypeAttributeDescription
events Events

To reduce the middlewares configuration.

targets Targets

To get targets information.

webpackConfiguration WebpackConfiguration

To get a target webpack configuration in order to instantiate the middlewares.

webpackPluginInfo WebpackPluginInfo

To get the name of the plugin and use it on the webpack hook that resolves the file system when the middleware finishes bundling.

Public Members

public events: Events source

A local reference for the events service.

public targets: Targets source

A local reference for the targets service.

public webpackConfiguration: WebpackConfiguration source

A local reference for the webpackConfiguration service.

public webpackPluginInfo: WebpackPluginInfo source

A local reference for the plugin information.

Public Methods

public generate(targetToBuild: string, targetToServe: string): MiddlewaresInformation source

Generate the middlewares for a given target.

Params:

NameTypeAttributeDescription
targetToBuild string

The name of the target that will be builded on the middleware(s).

targetToServe string

The name of the target that will implement the middleware(s). When the other target is builded, it will assume that is on the distribution directory, and if the target serving it is being executed from the source directory it won't be able to use the dev middleware file system without hardcoding some relatives paths from the build to the source; to avoid that, the method gets the build path of this target, so when using getDirectory(), it will think they are both on the distribution directory and the paths can be created relative to that.