dev.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // @ts-check
  2. import path from 'node:path'
  3. const resolve = (/** @type {string} */ p) =>
  4. path.resolve(import.meta.dirname, '../../packages', p)
  5. /**
  6. * @param {Object} [env]
  7. * @param {boolean} [env.browser]
  8. * @returns {import('vite').Plugin}
  9. */
  10. export function DevPlugin({ browser = false } = {}) {
  11. return {
  12. name: 'dev-plugin',
  13. config() {
  14. return {
  15. resolve: {
  16. alias: {
  17. 'vue/vapor': resolve('runtime-vapor/src'),
  18. vue: resolve('vue/src/runtime.ts'),
  19. '@vue/runtime-core': resolve('runtime-core/src'),
  20. '@vue/runtime-dom': resolve('runtime-dom/src'),
  21. '@vue/runtime-vapor': resolve('runtime-vapor/src'),
  22. '@vue/compiler-core': resolve('compiler-core/src'),
  23. '@vue/compiler-dom': resolve('compiler-dom/src'),
  24. '@vue/compiler-vapor': resolve('compiler-vapor/src'),
  25. '@vue/compiler-sfc': resolve('compiler-sfc/src'),
  26. '@vue/compiler-ssr': resolve('compiler-ssr/src'),
  27. '@vue/reactivity': resolve('reactivity/src'),
  28. '@vue/shared': resolve('shared/src'),
  29. '@vue/runtime-shared': resolve('runtime-shared/src'),
  30. },
  31. },
  32. define: {
  33. __COMMIT__: `"__COMMIT__"`,
  34. __VERSION__: `"0.0.0"`,
  35. __DEV__: `true`,
  36. // this is only used during Vue's internal tests
  37. __TEST__: `false`,
  38. // If the build is expected to run directly in the browser (global / esm builds)
  39. __BROWSER__: String(browser),
  40. __GLOBAL__: String(false),
  41. __ESM_BUNDLER__: String(true),
  42. __ESM_BROWSER__: String(false),
  43. // is targeting Node (SSR)?
  44. __NODE_JS__: String(false),
  45. // need SSR-specific branches?
  46. __SSR__: String(false),
  47. __BENCHMARK__: 'false',
  48. // 2.x compat build
  49. __COMPAT__: String(false),
  50. // feature flags
  51. __FEATURE_SUSPENSE__: `true`,
  52. __FEATURE_OPTIONS_API__: `true`,
  53. __FEATURE_PROD_DEVTOOLS__: `false`,
  54. },
  55. }
  56. },
  57. }
  58. }