router.js 880 B

123456789101112131415161718192021222324252627
  1. const { chalk } = require('@vue/cli-shared-utils')
  2. module.exports = cli => {
  3. cli.injectFeature({
  4. name: 'Router',
  5. value: 'router',
  6. description: 'Structure the app with dynamic pages',
  7. link: 'https://router.vuejs.org/'
  8. })
  9. cli.injectPrompt({
  10. name: 'historyMode',
  11. when: answers => answers.features.includes('router'),
  12. type: 'confirm',
  13. message: `Use history mode for router? ${chalk.yellow(`(Requires proper server setup for index fallback in production)`)}`,
  14. description: `By using the HTML5 History API, the URLs don't need the '#' character anymore.`,
  15. link: 'https://router.vuejs.org/guide/essentials/history-mode.html'
  16. })
  17. cli.onPromptComplete((answers, options) => {
  18. if (answers.features.includes('router')) {
  19. options.plugins['@vue/cli-plugin-router'] = {
  20. historyMode: answers.historyMode
  21. }
  22. }
  23. })
  24. }