index.js 768 B

1234567891011121314151617181920212223242526272829
  1. module.exports = (api, options = {}, rootOptions = {}) => {
  2. api.injectImports(api.entryFile, `import store from './store'`)
  3. if (rootOptions.vueVersion === '3') {
  4. api.transformScript(api.entryFile, require('./injectUseStore'))
  5. api.extendPackage({
  6. dependencies: {
  7. vuex: '^4.0.0-0'
  8. }
  9. })
  10. api.render('./template-vue3', {})
  11. } else {
  12. api.injectRootOptions(api.entryFile, `store`)
  13. api.extendPackage({
  14. dependencies: {
  15. vuex: '^3.4.0'
  16. }
  17. })
  18. api.render('./template', {})
  19. }
  20. if (api.invoking && api.hasPlugin('typescript')) {
  21. /* eslint-disable-next-line node/no-extraneous-require */
  22. const convertFiles = require('@vue/cli-plugin-typescript/generator/convert')
  23. convertFiles(api)
  24. }
  25. }