dev.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. __E2E_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. __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: `false`,
  55. },
  56. }
  57. },
  58. }
  59. }