inferRootOptions.js 796 B

123456789101112131415161718192021222324252627282930313233
  1. // Infer rootOptions for individual generators being invoked
  2. // in an existing project.
  3. module.exports = function inferRootOptions (pkg) {
  4. const rootOptions = {}
  5. const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies)
  6. // projectName
  7. rootOptions.projectName = pkg.name
  8. // router
  9. if ('vue-router' in deps) {
  10. rootOptions.router = true
  11. }
  12. // vuex
  13. if ('vuex' in deps) {
  14. rootOptions.vuex = true
  15. }
  16. // cssPreprocessors
  17. if ('sass' in deps) {
  18. rootOptions.cssPreprocessor = 'sass'
  19. } else if ('node-sass' in deps) {
  20. rootOptions.cssPreprocessor = 'node-sass'
  21. } else if ('less-loader' in deps) {
  22. rootOptions.cssPreprocessor = 'less'
  23. } else if ('stylus-loader' in deps) {
  24. rootOptions.cssPreprocessor = 'stylus'
  25. }
  26. return rootOptions
  27. }