dev.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. },
  54. }
  55. },
  56. }
  57. }