2
0

dev.js 2.2 KB

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