fliphub-monorepo
Version:
the builder of builders
82 lines (63 loc) • 2.2 kB
Markdown
//github.com/fliphub/fliphub/wiki/hubs
[ ]: https://github.com/fliphub/fliphub/blob/master/packages/fliphub/src/hubs/PresetHub.js
[ ]: https://github.com/fliphub/fliphub/blob/master/packages/fliphub/src/core/configs/Bundler.js
[ ]: https://github.com/fliphub/fliphub/blob/master/packages/fliphub/src/core/configs/Core.js
[ ]: https://github.com/fliphub/fliphub/blob/master/packages/fliphub/src/core/configs/ContextConfig.js
- similar to [hubs][hubs], there are lifecycle methods available, however, these are not done through event emitting, they are done using the [built-in PresetHub][presethub] - the same functionality could be achieved by adding your own hub.
- all of the methods are optional
- depending on the flips, one `from<Name>`, and one `to<Name>` will be called per context (if they exist on the preset)
- in the `to<Name>`,
- the arguments passed in can be changed by calling methods to merge, set, get, or anything by reference
- if the returned value is a `real` value, it will be merged into the [BundlerConfig][BundlerConfig]
```js
class CustomPreset {
constructor() {
this.args = {}
}
setArgs(args) {
if (args) this.args = args
}
coreInit(workflow) {}
decorate(context, bundler, workflow) {}
postDecorate(context, bundler, workflow) {}
init(workflow) {}
fromWebpack(bundlerConfig, workflow) {}
fromRollup(bundlerConfig, workflow) {}
fromFuseBox(bundlerConfig, workflow) {}
toWebpack(bundlerConfig, workflow) {}
toRollup(bundlerConfig, workflow) {}
toFuseBox(bundlerConfig, workflow) {}
}
```
```js
const flips = new FlipHub({
apps: [{
presets: {
eh: new CustomPreset(),
},
name: 'canada',
entry: './src/index.js',
output: './public/canada',
}],
})
```
```js
const flips = FlipHub.init({
apps: [{
name: 'canada',
entry: './src/index.js',
output: './public/canada',
}],
}).create()
flips.addPresets({
eh: new CustomPreset('your initial non-built-in args if needed'),
})
flips.usePresets({
eh: 'arguments that would be passed in by .setArgs',
})
```
[ ]: https: