Home Reference Source
import ProjextWebpackRuntimeDefinitions from 'projext-plugin-webpack/src/plugins/runtimeDefinitions/index.js'
public class | source

ProjextWebpackRuntimeDefinitions

This is a webpack plugin that works with webpack.DefinePlugin in order to reload all definitions when the bundle changes.

Constructor Summary

Public Constructor
public

constructor(files: Array, definitionsFn: Function():Object, options: ProjextWebpackRuntimeDefinitionsOptions)

Method Summary

Public Methods
public

apply(compiler: Object)

This is called by webpack when the plugin is being processed.

public

Get the options that customize the plugin instance.

Public Constructors

public constructor(files: Array, definitionsFn: Function():Object, options: ProjextWebpackRuntimeDefinitionsOptions) source

Params:

NameTypeAttributeDescription
files Array

The list of files that need to change in order to reload the definitions.

definitionsFn Function():Object

When this function is called, it should return the object with the definitions.

options ProjextWebpackRuntimeDefinitionsOptions
  • optional
  • default: {}

The options to customize the plugin instance.

Throw:

Error

If files is not an Array.

Error

If files is empty.

Error

If definitionsFn is not a function.

Public Methods

public apply(compiler: Object) source

This is called by webpack when the plugin is being processed. The method will create a new instance of webpack.DefinePlugin and set all the values as "runtime values", so they'll get evaluated every time the bundle is generated. The method will also tap into the compile hook, so this plugin can refresh the values (by calling the definitionFn) when the bundle is about to be generated.

Params:

NameTypeAttributeDescription
compiler Object

The compiler information provided by webpack.

public getOptions(): ProjextWebpackRuntimeDefinitionsOptions source

Get the options that customize the plugin instance.