index.js 679 B

123456789101112131415161718192021222324
  1. module.exports = (api, options = {}) => {
  2. api.injectImports(api.entryFile, `import router from './router'`)
  3. api.injectRootOptions(api.entryFile, `router`)
  4. api.extendPackage({
  5. dependencies: {
  6. 'vue-router': '^3.2.0'
  7. }
  8. })
  9. api.render('./template', {
  10. historyMode: options.historyMode,
  11. doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript'),
  12. hasTypeScript: api.hasPlugin('typescript')
  13. })
  14. if (api.invoking) {
  15. if (api.hasPlugin('typescript')) {
  16. /* eslint-disable-next-line node/no-extraneous-require */
  17. const convertFiles = require('@vue/cli-plugin-typescript/generator/convert')
  18. convertFiles(api)
  19. }
  20. }
  21. }