Home Reference Source

Function

Static Public Summary
public

useExpress(expressApp: Express, targetToBuild: string, targetToServe: string): MiddlewaresInformation

Implements the Webpack middlewares for a target on an Express app.

public

useJimpex(jimpexApp: Jimpex, targetToBuild: string, targetToServe: string): MiddlewaresInformation

Implements the Webpack middlewares for a target on a Jimpex app.

public

Generate a Provider with an already defined getDirectory and getFileSystem functions.

Static Public

public useExpress(expressApp: Express, targetToBuild: string, targetToServe: string): MiddlewaresInformation source

import useExpress from 'projext-plugin-webpack/src/express.js'

Implements the Webpack middlewares for a target on an Express app.

Params:

NameTypeAttributeDescription
expressApp Express

The app where the middlewares are going to be used.

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.

public useJimpex(jimpexApp: Jimpex, targetToBuild: string, targetToServe: string): MiddlewaresInformation source

import useJimpex from 'projext-plugin-webpack/src/jimpex.js'

Implements the Webpack middlewares for a target on a Jimpex app.

Params:

NameTypeAttributeDescription
jimpexApp Jimpex

The app where the middlewares are going to be registered.

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.

public webpackFrontendFs(getDirectory: DevMiddlewareGetDirectory, getFileSystem: DevMiddlewareGetFileSystem): Provider source

import {webpackFrontendFs} from 'projext-plugin-webpack/src/jimpex/frontendFs.js'

Generate a Provider with an already defined getDirectory and getFileSystem functions.

Params:

NameTypeAttributeDescription
getDirectory DevMiddlewareGetDirectory

A function to get the directory the Webpack middleware is using.

getFileSystem DevMiddlewareGetFileSystem

A function to get the virtual file system the Webpack middleware uses. It uses a Promise in order to avoid accessing it before the middleware finishes compiling.

Return:

Provider

Example:

// Generate the provider
const provider = webpackFrontendFs(() => 'some-dir', () => middleware.fs);
// Register it on the container
container.register(provider);
// Getting access to the service instance
const frontendFs = container.get('frontendFs');