dev.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. Run Rollup in watch mode for development.
  3. To specific the package to watch, simply pass its name and the desired build
  4. formats to watch (defaults to "global"):
  5. ```
  6. # name supports fuzzy match. will watch all packages with name containing "dom"
  7. yarn dev dom
  8. # specify the format to output
  9. yarn dev core --formats cjs
  10. # Can also drop all __DEV__ blocks with:
  11. __DEV__=false yarn dev
  12. ```
  13. */
  14. const execa = require('execa')
  15. const { fuzzyMatchTarget } = require('./utils')
  16. const args = require('minimist')(process.argv.slice(2))
  17. const target = args._.length ? fuzzyMatchTarget(args._)[0] : 'vue'
  18. const formats = args.formats || args.f
  19. const sourceMap = args.sourcemap || args.s
  20. const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7)
  21. execa(
  22. 'rollup',
  23. [
  24. '-wc',
  25. '--environment',
  26. [
  27. `COMMIT:${commit}`,
  28. `TARGET:${target}`,
  29. `FORMATS:${formats || 'global'}`,
  30. sourceMap ? `SOURCE_MAP:true` : ``
  31. ]
  32. .filter(Boolean)
  33. .join(',')
  34. ],
  35. {
  36. stdio: 'inherit'
  37. }
  38. )