config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. module.exports = api => {
  2. api.describeConfig({
  3. id: 'org.vue.vue-cli',
  4. name: 'Vue CLI',
  5. description: 'org.vue.vue-webpack.config.vue-cli.description',
  6. link: 'https://cli.vuejs.org/config/',
  7. files: {
  8. vue: {
  9. js: ['vue.config.js']
  10. }
  11. },
  12. icon: '/public/vue-cli.png',
  13. onRead: ({ data }) => ({
  14. prompts: [
  15. {
  16. name: 'publicPath',
  17. type: 'input',
  18. default: '/',
  19. value: data.vue && data.vue.publicPath,
  20. message: 'org.vue.vue-webpack.config.vue-cli.publicPath.label',
  21. description: 'org.vue.vue-webpack.config.vue-cli.publicPath.description',
  22. group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
  23. link: 'https://cli.vuejs.org/config/#publicPath'
  24. },
  25. {
  26. name: 'outputDir',
  27. type: 'input',
  28. default: 'dist',
  29. value: data.vue && data.vue.outputDir,
  30. validate: input => !!input,
  31. message: 'org.vue.vue-webpack.config.vue-cli.outputDir.label',
  32. description: 'org.vue.vue-webpack.config.vue-cli.outputDir.description',
  33. group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
  34. link: 'https://cli.vuejs.org/config/#outputdir'
  35. },
  36. {
  37. name: 'assetsDir',
  38. type: 'input',
  39. default: '',
  40. value: data.vue && data.vue.assetsDir,
  41. message: 'org.vue.vue-webpack.config.vue-cli.assetsDir.label',
  42. description: 'org.vue.vue-webpack.config.vue-cli.assetsDir.description',
  43. group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
  44. link: 'https://cli.vuejs.org/config/#assetsdir'
  45. },
  46. {
  47. name: 'runtimeCompiler',
  48. type: 'confirm',
  49. default: false,
  50. value: data.vue && data.vue.runtimeCompiler,
  51. message: 'org.vue.vue-webpack.config.vue-cli.runtimeCompiler.label',
  52. description: 'org.vue.vue-webpack.config.vue-cli.runtimeCompiler.description',
  53. group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
  54. link: 'https://cli.vuejs.org/config/#runtimecompiler'
  55. },
  56. {
  57. name: 'productionSourceMap',
  58. type: 'confirm',
  59. default: true,
  60. value: data.vue && data.vue.productionSourceMap,
  61. message: 'org.vue.vue-webpack.config.vue-cli.productionSourceMap.label',
  62. description: 'org.vue.vue-webpack.config.vue-cli.productionSourceMap.description',
  63. group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
  64. link: 'https://cli.vuejs.org/config/#productionsourcemap'
  65. },
  66. {
  67. name: 'parallel',
  68. type: 'confirm',
  69. default: require('os').cpus().length > 1,
  70. value: data.vue && data.vue.parallel,
  71. message: 'org.vue.vue-webpack.config.vue-cli.parallel.label',
  72. description: 'org.vue.vue-webpack.config.vue-cli.parallel.description',
  73. group: 'org.vue.vue-webpack.config.vue-cli.groups.general',
  74. link: 'https://cli.vuejs.org/config/#parallel'
  75. },
  76. {
  77. name: 'css.modules',
  78. type: 'confirm',
  79. default: false,
  80. value: data.vue && data.vue.css && data.vue.css.modules,
  81. message: 'org.vue.vue-webpack.config.vue-cli.css.modules.label',
  82. description: 'org.vue.vue-webpack.config.vue-cli.css.modules.description',
  83. group: 'org.vue.vue-webpack.config.vue-cli.groups.css',
  84. link: 'https://cli.vuejs.org/config/#css-modules'
  85. },
  86. {
  87. name: 'css.extract',
  88. type: 'confirm',
  89. default: true,
  90. value: data.vue && data.vue.css && data.vue.css.extract,
  91. message: 'org.vue.vue-webpack.config.vue-cli.css.extract.label',
  92. description: 'org.vue.vue-webpack.config.vue-cli.css.extract.description',
  93. group: 'org.vue.vue-webpack.config.vue-cli.groups.css',
  94. link: 'https://cli.vuejs.org/config/#css-extract'
  95. },
  96. {
  97. name: 'css.sourceMap',
  98. type: 'confirm',
  99. default: false,
  100. value: data.vue && data.vue.css && data.vue.css.sourceMap,
  101. message: 'org.vue.vue-webpack.config.vue-cli.css.sourceMap.label',
  102. description: 'org.vue.vue-webpack.config.vue-cli.css.sourceMap.description',
  103. group: 'org.vue.vue-webpack.config.vue-cli.groups.css',
  104. link: 'https://cli.vuejs.org/config/#css-sourcemap'
  105. }
  106. ]
  107. }),
  108. onWrite: async ({ api, prompts }) => {
  109. const vueData = {}
  110. for (const prompt of prompts) {
  111. vueData[prompt.id] = await api.getAnswer(prompt.id)
  112. }
  113. api.setData('vue', vueData)
  114. }
  115. })
  116. }