dev.js 2.1 KB

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