@hzab/vite-config 0.0.2-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.
- package/CHANGELOG.md +95 -83
- package/LICENSE +21 -21
- package/README.md +184 -173
- package/dist/create-app-vite-config.cjs +160 -27
- package/dist/create-app-vite-config.cjs.map +1 -1
- package/dist/create-app-vite-config.js +160 -27
- package/dist/create-app-vite-config.js.map +1 -1
- package/dist/create-library-vite-config.cjs +39 -4
- package/dist/create-library-vite-config.cjs.map +1 -1
- package/dist/create-library-vite-config.js +38 -3
- package/dist/create-library-vite-config.js.map +1 -1
- package/dist/create-package-vitest-config.cjs.map +1 -1
- package/dist/create-package-vitest-config.js.map +1 -1
- package/dist/create-vite-config.cjs +160 -27
- package/dist/create-vite-config.cjs.map +1 -1
- package/dist/create-vite-config.js +160 -27
- package/dist/create-vite-config.js.map +1 -1
- package/dist/index.cjs +198 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +199 -31
- package/dist/index.js.map +1 -1
- package/dist/plugins/copy.cjs.map +1 -1
- package/dist/plugins/copy.js.map +1 -1
- package/dist/plugins/hash-deploy.cjs +150 -25
- package/dist/plugins/hash-deploy.cjs.map +1 -1
- package/dist/plugins/hash-deploy.d.cts +16 -5
- package/dist/plugins/hash-deploy.d.ts +16 -5
- package/dist/plugins/hash-deploy.js +150 -25
- package/dist/plugins/hash-deploy.js.map +1 -1
- package/dist/plugins/less-tilde.cjs.map +1 -1
- package/dist/plugins/less-tilde.d.cts +17 -2
- package/dist/plugins/less-tilde.d.ts +17 -2
- package/dist/plugins/less-tilde.js.map +1 -1
- package/dist/plugins/lifecycle.cjs.map +1 -1
- package/dist/plugins/lifecycle.js.map +1 -1
- package/dist/plugins/public-assets.cjs.map +1 -1
- package/dist/plugins/public-assets.js.map +1 -1
- package/dist/plugins/public-config.cjs.map +1 -1
- package/dist/plugins/public-config.js.map +1 -1
- package/dist/plugins/react-compiler.cjs.map +1 -1
- package/dist/plugins/react-compiler.js.map +1 -1
- package/dist/plugins/relative-base.cjs.map +1 -1
- package/dist/plugins/relative-base.js.map +1 -1
- package/dist/plugins/stub-less.cjs.map +1 -1
- package/dist/plugins/stub-less.js.map +1 -1
- package/dist/plugins/svg-react.cjs.map +1 -1
- package/dist/plugins/svg-react.js.map +1 -1
- package/dist/types.d.cts +19 -8
- package/dist/types.d.ts +19 -8
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.js.map +1 -1
- package/docs/README.md +15 -15
- package/docs/abt-management-ui/vite.config.mts +226 -226
- package/docs/api.md +404 -366
- package/docs/migration-from-webpack.md +723 -722
- package/docs/sync-public-path.md +52 -52
- package/docs/vite-config-integration.md +477 -476
- package/docs/vite-pnpm-integration.md +279 -279
- package/docs/vs-ccc-vite-config.md +26 -26
- package/docs/webpack-gap.md +108 -107
- package/package.json +1 -1
- package/src/client.d.ts +9 -9
- package/src/create-app-vite-config.ts +236 -218
- package/src/create-library-vite-config.ts +248 -199
- package/src/create-package-vitest-config.ts +54 -54
- package/src/create-vite-config.ts +22 -22
- package/src/index.ts +41 -42
- package/src/plugins/copy.ts +25 -25
- package/src/plugins/hash-deploy.ts +239 -199
- package/src/plugins/hash-dir-name.ts +212 -0
- package/src/plugins/less-tilde.ts +72 -44
- package/src/plugins/lifecycle.ts +40 -40
- package/src/plugins/public-assets.ts +28 -28
- package/src/plugins/public-config.ts +34 -34
- package/src/plugins/react-compiler.ts +32 -32
- package/src/plugins/relative-base.ts +20 -20
- package/src/plugins/stub-less.ts +26 -26
- package/src/plugins/svg-react.ts +90 -90
- package/src/svg-react-runtime.ts +4 -4
- package/src/svg-react.d.ts +6 -6
- package/src/types.ts +325 -314
- package/src/vitest-types.ts +20 -20
- package/src/vitest.ts +2 -2
- package/templates/src/vite-env.d.ts +2 -2
- package/templates/tsconfig.json +12 -12
- package/templates/vite.config.ts +26 -26
package/src/vitest-types.ts
CHANGED
|
@@ -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" />
|
package/templates/tsconfig.json
CHANGED
|
@@ -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
|
+
}
|
package/templates/vite.config.ts
CHANGED
|
@@ -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
|
+
);
|