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: resolve('vue/src/runtime-with-vapor.ts'),
  18. '@vue/runtime-core': resolve('runtime-core/src'),
  19. '@vue/runtime-dom': resolve('runtime-dom/src'),
  20. '@vue/runtime-vapor': resolve('runtime-vapor/src'),
  21. '@vue/compiler-core': resolve('compiler-core/src'),
  22. '@vue/compiler-dom': resolve('compiler-dom/src'),
  23. '@vue/compiler-vapor': resolve('compiler-vapor/src'),
  24. '@vue/compiler-sfc': resolve('compiler-sfc/src'),
  25. '@vue/compiler-ssr': resolve('compiler-ssr/src'),
  26. '@vue/reactivity': resolve('reactivity/src'),
  27. '@vue/shared': resolve('shared/src'),
  28. '@vue/runtime-shared': resolve('runtime-shared/src'),
  29. },
  30. },
  31. define: {
  32. __COMMIT__: `"__COMMIT__"`,
  33. __VERSION__: `"0.0.0"`,
  34. __DEV__: `true`,
  35. // this is only used during Vue's internal tests
  36. __TEST__: `false`,
  37. // If the build is expected to run directly in the browser (global / esm builds)
  38. __BROWSER__: String(browser),
  39. __GLOBAL__: String(false),
  40. __ESM_BUNDLER__: String(true),
  41. __ESM_BROWSER__: String(false),
  42. // is targeting Node (SSR)?
  43. __NODE_JS__: String(false),
  44. // need SSR-specific branches?
  45. __SSR__: String(false),
  46. __BENCHMARK__: 'false',
  47. // 2.x compat build
  48. __COMPAT__: String(false),
  49. // feature flags
  50. __FEATURE_SUSPENSE__: `true`,
  51. __FEATURE_OPTIONS_API__: `true`,
  52. __FEATURE_PROD_DEVTOOLS__: `false`,
  53. __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: `false`,
  54. },
  55. }
  56. },
  57. }
  58. }