dev.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. }
  33. },
  34. define: {
  35. __COMMIT__: `"__COMMIT__"`,
  36. __VERSION__: `"0.0.0"`,
  37. __DEV__: `true`,
  38. // this is only used during Vue's internal tests
  39. __TEST__: `false`,
  40. // If the build is expected to run directly in the browser (global / esm builds)
  41. __BROWSER__: String(browser),
  42. __GLOBAL__: String(false),
  43. __ESM_BUNDLER__: String(true),
  44. __ESM_BROWSER__: String(false),
  45. // is targeting Node (SSR)?
  46. __NODE_JS__: String(false),
  47. // need SSR-specific branches?
  48. __SSR__: String(false),
  49. // 2.x compat build
  50. __COMPAT__: String(false),
  51. // feature flags
  52. __FEATURE_SUSPENSE__: `true`,
  53. __FEATURE_OPTIONS_API__: `true`,
  54. __FEATURE_PROD_DEVTOOLS__: `false`
  55. }
  56. }
  57. }
  58. }
  59. }