sarsamurmu / reboost

A super fast dev server for rapid web development
MIT License
61 stars 3 forks source link

How to pass a plugin config object to the plugin itself during bootstrap #35

Closed GHNewbiee closed 4 years ago

GHNewbiee commented 4 years ago

I have had a look at all plugins. Unfortunately, I cannot still figure out a standard way how to pass a plugin config object, e.g.

start({ // `Reboost` config object
  ...
  plugins: [
    samplePlugin({ // `samplePlugin` config object
      pluginSpecificOptions 
    })
  ]
});

into .../plugin-sample/src/index.ts samplePlugin function when Reboost starts.

I have seen that, most of the times, an empty object is passed in options argument of the function:

export const CSSPlugin = (options: CSSPluginOptions = {}): ReboostPlugin => {, export = (options: Babel.TransformOptions = {}): ReboostPlugin => {..., export const esbuildPlugin = (options: esbuildPluginOptions = {}): ReboostPlugin => {..., export const PostCSSPlugin = (options: PostCSSPluginOptions = {}): ReboostPlugin => ({ export = (options: SveltePluginOptions = {}): ReboostPlugin => { or, even simpler export = (options: Options = {}): ReboostPlugin => {

Please, enlighten me. Tia

GHNewbiee commented 4 years ago

Sorry, empty object is the default value when options is not defined, isn't it? So, options does always represent the plugin config object.

sarsamurmu commented 4 years ago

Yes, you're correct.