Skip to main content

Decorators

There are decorators exported from @roots/bud-framework/extension/decorators.

@bind

Bind a class method.

extension.ts
import {Extension} from '@roots/bud-framework/extension'
import {bind} from '@roots/bud-framework/extension/decorators'

class MyExtension extends Extension {
@bind
public myMethod() {}
}

@label

extension.ts
import {Extension} from '@roots/bud-framework/extension'
import {label} from '@roots/bud-framework/extension/decorators'

@label('my-extension')
class MyExtension extends Extension {}

@dependsOn

extension.ts
import {Extension} from '@roots/bud-framework/extension'
import {dependsOn, label} from '@roots/bud-framework/extension/decorators'

@label('my-extension')
@dependsOn(['@roots/bud-postcss'])
class MyExtension extends Extension {}

@dependsOnOptional

extension.ts
import {Extension} from '@roots/bud-framework/extension'
import {
dependsOnOptional,
label,
} from '@roots/bud-framework/extension/decorators'

@label('my-extension')
@dependsOnOptional(['@roots/bud-postcss'])
class MyExtension extends Extension {}

@options

extension.ts
import {Extension} from '@roots/bud-framework/extension'
import {options, label} from '@roots/bud-framework/extension/decorators'

@label('my-extension')
@options({foo: 'bar'})
class MyExtension extends Extension {}

@plugin

extension.ts
import {Extension} from '@roots/bud-framework/extension'
import {options, label} from '@roots/bud-framework/extension/decorators'
import PluginConstructor from 'webpack-manifest-plugin'

@label('my-extension')
@plugin(PluginConstructor)
class MyExtension extends Extension {}