@roots/bud-extensions
Version:
bud.js core module
40 lines (39 loc) • 1.15 kB
JavaScript
import { __decorate } from "tslib";
import { Bud } from '@roots/bud-framework/bud';
import { Extension } from '@roots/bud-framework/extension';
import { bind, label, options, plugin, } from '@roots/bud-framework/extension/decorators';
import { default as Webpack, } from '@roots/bud-support/webpack';
/**
* Define plugin configuration
*/
let BudDefine = class BudDefine extends Extension {
/**
* {@link Extension.register}
*/
async register({ env }) {
if (!env.getPublicEnv())
return;
this.setOptions(Object.entries(env.getPublicEnv()).reduce((values, [key, value]) => ({
...values,
[key]: JSON.stringify(value),
}), {}));
}
/**
* {@link Extension.when}
*/
when() {
return this.options && Object.keys(this.options).length > 0;
}
};
__decorate([
bind
], BudDefine.prototype, "register", null);
__decorate([
bind
], BudDefine.prototype, "when", null);
BudDefine = __decorate([
label(`@roots/bud-extensions/webpack-define-plugin`),
plugin(Webpack.DefinePlugin),
options({})
], BudDefine);
export default BudDefine;