@hzab/vite-config 0.0.3-alpha.0 → 0.0.3-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.md +95 -85
  2. package/LICENSE +21 -21
  3. package/README.md +184 -173
  4. package/dist/create-app-vite-config.cjs +160 -27
  5. package/dist/create-app-vite-config.cjs.map +1 -1
  6. package/dist/create-app-vite-config.js +160 -27
  7. package/dist/create-app-vite-config.js.map +1 -1
  8. package/dist/create-library-vite-config.cjs +34 -3
  9. package/dist/create-library-vite-config.cjs.map +1 -1
  10. package/dist/create-library-vite-config.js +33 -2
  11. package/dist/create-library-vite-config.js.map +1 -1
  12. package/dist/create-package-vitest-config.cjs.map +1 -1
  13. package/dist/create-package-vitest-config.js.map +1 -1
  14. package/dist/create-vite-config.cjs +160 -27
  15. package/dist/create-vite-config.cjs.map +1 -1
  16. package/dist/create-vite-config.js +160 -27
  17. package/dist/create-vite-config.js.map +1 -1
  18. package/dist/index.cjs +193 -29
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +194 -30
  23. package/dist/index.js.map +1 -1
  24. package/dist/plugins/copy.cjs.map +1 -1
  25. package/dist/plugins/copy.js.map +1 -1
  26. package/dist/plugins/hash-deploy.cjs +150 -25
  27. package/dist/plugins/hash-deploy.cjs.map +1 -1
  28. package/dist/plugins/hash-deploy.d.cts +16 -5
  29. package/dist/plugins/hash-deploy.d.ts +16 -5
  30. package/dist/plugins/hash-deploy.js +150 -25
  31. package/dist/plugins/hash-deploy.js.map +1 -1
  32. package/dist/plugins/less-tilde.cjs.map +1 -1
  33. package/dist/plugins/less-tilde.js.map +1 -1
  34. package/dist/plugins/lifecycle.cjs.map +1 -1
  35. package/dist/plugins/lifecycle.js.map +1 -1
  36. package/dist/plugins/public-assets.cjs.map +1 -1
  37. package/dist/plugins/public-assets.js.map +1 -1
  38. package/dist/plugins/public-config.cjs.map +1 -1
  39. package/dist/plugins/public-config.js.map +1 -1
  40. package/dist/plugins/react-compiler.cjs.map +1 -1
  41. package/dist/plugins/react-compiler.js.map +1 -1
  42. package/dist/plugins/relative-base.cjs.map +1 -1
  43. package/dist/plugins/relative-base.js.map +1 -1
  44. package/dist/plugins/stub-less.cjs.map +1 -1
  45. package/dist/plugins/stub-less.js.map +1 -1
  46. package/dist/plugins/svg-react.cjs.map +1 -1
  47. package/dist/plugins/svg-react.js.map +1 -1
  48. package/dist/types.d.cts +19 -8
  49. package/dist/types.d.ts +19 -8
  50. package/dist/vitest.cjs.map +1 -1
  51. package/dist/vitest.js.map +1 -1
  52. package/docs/README.md +15 -15
  53. package/docs/abt-management-ui/vite.config.mts +226 -226
  54. package/docs/api.md +404 -366
  55. package/docs/migration-from-webpack.md +723 -722
  56. package/docs/sync-public-path.md +52 -52
  57. package/docs/vite-config-integration.md +477 -476
  58. package/docs/vite-pnpm-integration.md +279 -279
  59. package/docs/vs-ccc-vite-config.md +26 -26
  60. package/docs/webpack-gap.md +108 -107
  61. package/package.json +1 -1
  62. package/src/client.d.ts +9 -9
  63. package/src/create-app-vite-config.ts +236 -218
  64. package/src/create-library-vite-config.ts +248 -205
  65. package/src/create-package-vitest-config.ts +54 -54
  66. package/src/create-vite-config.ts +22 -22
  67. package/src/index.ts +41 -42
  68. package/src/plugins/copy.ts +25 -25
  69. package/src/plugins/hash-deploy.ts +239 -199
  70. package/src/plugins/hash-dir-name.ts +212 -0
  71. package/src/plugins/less-tilde.ts +72 -72
  72. package/src/plugins/lifecycle.ts +40 -40
  73. package/src/plugins/public-assets.ts +28 -28
  74. package/src/plugins/public-config.ts +34 -34
  75. package/src/plugins/react-compiler.ts +32 -32
  76. package/src/plugins/relative-base.ts +20 -20
  77. package/src/plugins/stub-less.ts +26 -26
  78. package/src/plugins/svg-react.ts +90 -90
  79. package/src/svg-react-runtime.ts +4 -4
  80. package/src/svg-react.d.ts +6 -6
  81. package/src/types.ts +325 -314
  82. package/src/vitest-types.ts +20 -20
  83. package/src/vitest.ts +2 -2
  84. package/templates/src/vite-env.d.ts +2 -2
  85. package/templates/tsconfig.json +12 -12
  86. package/templates/vite.config.ts +26 -26
@@ -1,20 +1,20 @@
1
- import type { AliasOptions, PluginOption } from "vite";
2
- import type { ViteUserConfig as VitestUserConfig } from "vitest/config";
3
-
4
- export interface CreatePackageVitestConfigOptions {
5
- packageRoot: string;
6
- /**
7
- * 与 Vite `resolve.alias` 相同:
8
- * - `Record<string, string>`
9
- * - `{ find, replacement }[]`
10
- */
11
- alias?: AliasOptions;
12
- react?: boolean;
13
- stubLess?: boolean;
14
- environment?: "happy-dom" | "jsdom" | "node" | "edge-runtime" | string;
15
- include?: string[];
16
- setupFiles?: string[];
17
- plugins?: PluginOption[];
18
- vite?: VitestUserConfig;
19
- configure?: (config: VitestUserConfig) => VitestUserConfig;
20
- }
1
+ import type { AliasOptions, PluginOption } from "vite";
2
+ import type { ViteUserConfig as VitestUserConfig } from "vitest/config";
3
+
4
+ export interface CreatePackageVitestConfigOptions {
5
+ packageRoot: string;
6
+ /**
7
+ * 与 Vite `resolve.alias` 相同:
8
+ * - `Record<string, string>`
9
+ * - `{ find, replacement }[]`
10
+ */
11
+ alias?: AliasOptions;
12
+ react?: boolean;
13
+ stubLess?: boolean;
14
+ environment?: "happy-dom" | "jsdom" | "node" | "edge-runtime" | string;
15
+ include?: string[];
16
+ setupFiles?: string[];
17
+ plugins?: PluginOption[];
18
+ vite?: VitestUserConfig;
19
+ configure?: (config: VitestUserConfig) => VitestUserConfig;
20
+ }
package/src/vitest.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { createPackageVitestConfig } from "./create-package-vitest-config.ts";
2
- export type { CreatePackageVitestConfigOptions } from "./vitest-types.ts";
1
+ export { createPackageVitestConfig } from "./create-package-vitest-config.ts";
2
+ export type { CreatePackageVitestConfigOptions } from "./vitest-types.ts";
@@ -1,2 +1,2 @@
1
- /// <reference types="vite/client" />
2
- /// <reference types="@hzab/vite-config/client" />
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="@hzab/vite-config/client" />
@@ -1,12 +1,12 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "strict": true,
7
- "jsx": "react-jsx",
8
- "skipLibCheck": true,
9
- "noEmit": true
10
- },
11
- "include": ["src"]
12
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "strict": true,
7
+ "jsx": "react-jsx",
8
+ "skipLibCheck": true,
9
+ "noEmit": true
10
+ },
11
+ "include": ["src"]
12
+ }
@@ -1,26 +1,26 @@
1
- import { readFileSync } from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { defineConfig } from "vite";
5
- import { createViteConfig } from "@hzab/vite-config";
6
-
7
- const rootDir = path.dirname(fileURLToPath(import.meta.url));
8
-
9
- // 从应用 package.json 读取版本号(勿注入 @hzab/vite-config 自身的版本)
10
- const { version } = JSON.parse(readFileSync(path.resolve(rootDir, "package.json"), "utf-8"));
11
-
12
- export default defineConfig(({ command, mode }) =>
13
- createViteConfig({
14
- rootDir,
15
- command,
16
- mode,
17
- vite: {
18
- define: {
19
- // 源码中的 process.env.PACKAGE_VERSION 在构建时替换为应用版本号
20
- "process.env.PACKAGE_VERSION": JSON.stringify(version),
21
- // 自定义键示例:透传构建时环境变量(未设置时回退默认值)
22
- // "process.env.CUSTOM_KEY": JSON.stringify(process.env.CUSTOM_KEY ?? ""),
23
- },
24
- },
25
- }),
26
- );
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { defineConfig } from "vite";
5
+ import { createViteConfig } from "@hzab/vite-config";
6
+
7
+ const rootDir = path.dirname(fileURLToPath(import.meta.url));
8
+
9
+ // 从应用 package.json 读取版本号(勿注入 @hzab/vite-config 自身的版本)
10
+ const { version } = JSON.parse(readFileSync(path.resolve(rootDir, "package.json"), "utf-8"));
11
+
12
+ export default defineConfig(({ command, mode }) =>
13
+ createViteConfig({
14
+ rootDir,
15
+ command,
16
+ mode,
17
+ vite: {
18
+ define: {
19
+ // 源码中的 process.env.PACKAGE_VERSION 在构建时替换为应用版本号
20
+ "process.env.PACKAGE_VERSION": JSON.stringify(version),
21
+ // 自定义键示例:透传构建时环境变量(未设置时回退默认值)
22
+ // "process.env.CUSTOM_KEY": JSON.stringify(process.env.CUSTOM_KEY ?? ""),
23
+ },
24
+ },
25
+ }),
26
+ );