Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending pluginOptions in generator #850

Open
wietseva opened this issue Feb 17, 2018 · 1 comment
Open

Extending pluginOptions in generator #850

wietseva opened this issue Feb 17, 2018 · 1 comment

Comments

@wietseva
Copy link
Contributor

What problem does this feature solve?

Enabling custom cli plugins to extend pluginOptions with defaults or prompt answers.
Extending pluginPluginOptions with the generator api.extendPackage will currently just replace instead off merge pluginOptions.

Current Config vue.config.js

{
  lintOnSave: true,
  pluginOptions: {
    someOption: "Some option that was present"
  }
}

Extending pluginOptions generator.js

api.extendPackage({
  vue: {
    pluginOptions: {
      extraOption: "An extra option to be added"
    }
  }
})

In the resulting config vue.config.js someOption was removed.

{
  lintOnSave: true,
  pluginOptions: {
    extraOption: "An extra option to be added"
  }
}

What does the proposed API look like?

generator.js

api.extendPluginOptions( (options) => {
  options.extraOption = "An extra option to be added "
  return options
})

Resulting config vue.config.js

{
  lintOnSave: true,
  pluginOptions: {
    someOption: "Some option that was present"
    extraOption: "An extra option to be added"
  }
}
@wietseva wietseva changed the title Extending pluginOptions in generator [feature request] Extending pluginOptions in generator Feb 17, 2018
@wietseva
Copy link
Contributor Author

I've implemented this api with an importable function.
extendPluginOptions.js

Just import it in generator.js

const extendPluginOptions = require('./extendPluginOptions.js')
module.exports = (api, options) => {
  // modify plugin options
  extendPluginOptions(api, pluginOptions => {
    plugoptions.newOption = "some new option"   
    return pluginOptions
  })
}

@wietseva wietseva reopened this Feb 17, 2018
@yyx990803 yyx990803 changed the title [feature request] Extending pluginOptions in generator Extending pluginOptions in generator Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants