uni.js 938 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env node
  2. const { performance } = require('perf_hooks')
  3. global.__vite_start_time = performance.now()
  4. const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg))
  5. const filterIndex = process.argv.findIndex((arg) =>
  6. /^(?:-f|--filter)$/.test(arg)
  7. )
  8. if (debugIndex > 0) {
  9. let value = process.argv[debugIndex + 1]
  10. if (!value || value.startsWith('-')) {
  11. value = 'vite:*,uni:*'
  12. }
  13. process.env.DEBUG = value
  14. if (filterIndex > 0) {
  15. const filter = process.argv[filterIndex + 1]
  16. if (filter && !filter.startsWith('-')) {
  17. process.env.VITE_DEBUG_FILTER = filter
  18. }
  19. }
  20. }
  21. // uni-cli-shared 引入了 @vue/compiler-core,需要提前设置NODE_ENV,才能保证 @vue/compiler-core 加载的是对应环境的代码
  22. if (
  23. process.argv[2] === 'build' &&
  24. !process.argv.some((arg) => /^(?:-w|--watch)$/.test(arg))
  25. ) {
  26. process.env.NODE_ENV = 'production'
  27. }
  28. require('../dist/cli/index.js')