diff --git a/lib/extension.js b/lib/extension.js index bc583e1..3221cbb 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -1,12 +1,12 @@ import { __decorate } from "tslib"; import { Bud } from '@roots/bud-framework'; import { Extension } from '@roots/bud-framework/extension'; -import { bind, label } from '@roots/bud-framework/extension/decorators'; +import { bind, label, expose } from '@roots/bud-framework/extension/decorators'; import localtunnel from 'localtunnel/localtunnel.js'; let BudLocaltunnel = class BudLocaltunnel extends Extension { #devTunnel; async configAfter(bud) { - if (bud.isDevelopment) { + if (bud.isDevelopment && this.enabled) { this.#devTunnel = await localtunnel({ subdomain: bud.context.label.length > 3 ? bud.context.label : undefined, local_host: bud.server?.url.hostname, port: bud.server?.url.port }); const tunnelUrl = new URL(this.#devTunnel.url); bud.setPublicUrl(tunnelUrl); @@ -23,6 +23,7 @@ __decorate([ bind ], BudLocaltunnel.prototype, "configAfter", null); BudLocaltunnel = __decorate([ - label(`bud-localtunnel`) + label(`bud-localtunnel`), + expose(`localtunnel`) ], BudLocaltunnel); export default BudLocaltunnel; diff --git a/lib/types.d.ts b/lib/types.d.ts index 9ac4df2..56de46b 100644 --- a/lib/types.d.ts +++ b/lib/types.d.ts @@ -3,4 +3,7 @@ declare module '@roots/bud-framework' { interface Modules { 'bud-localtunnel': BudLocaltunnel; } + interface Bud { + localtunnel: BudLocaltunnel; + } } diff --git a/src/extension.ts b/src/extension.ts index 4751409..b00c564 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,13 +3,14 @@ import {Bud} from '@roots/bud-framework' import {Extension} from '@roots/bud-framework/extension' import type {WebpackPluginInstance} from '@roots/bud-framework/config' -import {bind, label} from '@roots/bud-framework/extension/decorators' +import {bind, label, expose} from '@roots/bud-framework/extension/decorators' import localtunnel from 'localtunnel/localtunnel.js' interface Options {} @label(`bud-localtunnel`) +@expose(`localtunnel`) export default class BudLocaltunnel extends Extension< Options, WebpackPluginInstance @@ -19,7 +20,7 @@ export default class BudLocaltunnel extends Extension< @bind public override async configAfter(bud: Bud) { - if(bud.isDevelopment) { + if(bud.isDevelopment && this.enabled) { this.#devTunnel = await localtunnel({ subdomain: bud.context.label.length > 3 ? bud.context.label : undefined, local_host: bud.server?.url.hostname, port: bud.server?.url.port }) const tunnelUrl = new URL(this.#devTunnel.url); diff --git a/src/types.ts b/src/types.ts index 530890c..03ef136 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,4 +4,8 @@ declare module '@roots/bud-framework' { interface Modules { 'bud-localtunnel': BudLocaltunnel } + + interface Bud { + localtunnel: BudLocaltunnel + } }