index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. module.exports = (api, options) => {
  2. api.render('./template', {
  3. doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript')
  4. })
  5. if (options.vueVersion === '3') {
  6. api.extendPackage({
  7. dependencies: {
  8. 'vue': '^3.0.0'
  9. },
  10. devDependencies: {
  11. '@vue/compiler-sfc': '^3.0.0'
  12. }
  13. })
  14. } else {
  15. api.extendPackage({
  16. dependencies: {
  17. 'vue': '^2.6.11'
  18. },
  19. devDependencies: {
  20. 'vue-template-compiler': '^2.6.11'
  21. }
  22. })
  23. }
  24. api.extendPackage({
  25. scripts: {
  26. 'serve': 'vue-cli-service serve',
  27. 'build': 'vue-cli-service build'
  28. },
  29. browserslist: [
  30. '> 1%',
  31. 'last 2 versions',
  32. 'not dead'
  33. ]
  34. })
  35. if (options.cssPreprocessor) {
  36. const deps = {
  37. sass: {
  38. sass: '^1.26.5',
  39. 'sass-loader': '^8.0.2'
  40. },
  41. 'node-sass': {
  42. 'node-sass': '^4.12.0',
  43. 'sass-loader': '^8.0.2'
  44. },
  45. 'dart-sass': {
  46. sass: '^1.26.5',
  47. 'sass-loader': '^8.0.2'
  48. },
  49. less: {
  50. 'less': '^3.0.4',
  51. 'less-loader': '^5.0.0'
  52. },
  53. stylus: {
  54. 'stylus': '^0.54.7',
  55. 'stylus-loader': '^3.0.2'
  56. }
  57. }
  58. api.extendPackage({
  59. devDependencies: deps[options.cssPreprocessor]
  60. })
  61. }
  62. // for v3 compatibility
  63. if (options.router && !api.hasPlugin('router')) {
  64. require('./router')(api, options, options)
  65. }
  66. // for v3 compatibility
  67. if (options.vuex && !api.hasPlugin('vuex')) {
  68. require('./vuex')(api, options, options)
  69. }
  70. // additional tooling configurations
  71. if (options.configs) {
  72. api.extendPackage(options.configs)
  73. }
  74. }