features.js 715 B

123456789101112131415161718192021222324252627
  1. const { chalk, toShortPluginId } = require('@vue/cli-shared-utils')
  2. exports.getFeatures = (preset) => {
  3. const features = []
  4. if (preset.router) {
  5. features.push('router')
  6. }
  7. if (preset.vuex) {
  8. features.push('vuex')
  9. }
  10. if (preset.cssPreprocessor) {
  11. features.push(preset.cssPreprocessor)
  12. }
  13. const plugins = Object.keys(preset.plugins).filter(dep => {
  14. return dep !== '@vue/cli-service'
  15. })
  16. features.push.apply(features, plugins)
  17. return features
  18. }
  19. exports.formatFeatures = (preset, lead, joiner) => {
  20. const features = exports.getFeatures(preset)
  21. return features.map(dep => {
  22. dep = toShortPluginId(dep)
  23. return `${lead || ''}${chalk.yellow(dep)}`
  24. }).join(joiner || ', ')
  25. }