fe-stack 0.0.4 → 0.0.6
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/README.md +6 -1
- package/package.json +1 -1
- package/vite.config.base.d.ts +6 -0
- package/vite.config.base.js +6 -3
package/README.md
CHANGED
|
@@ -120,6 +120,11 @@ import { createBaseConfig } from 'fe-stack/vite.config.base';
|
|
|
120
120
|
|
|
121
121
|
export default createBaseConfig(import.meta.dirname, {
|
|
122
122
|
mode: 'lib',
|
|
123
|
+
dtsConfig: {
|
|
124
|
+
// 自定义 vite-plugin-dts 配置
|
|
125
|
+
exclude: ['**/*.test.ts', '**/*.spec.ts'],
|
|
126
|
+
insertTypesEntry: true,
|
|
127
|
+
},
|
|
123
128
|
viteConfig: {
|
|
124
129
|
build: {
|
|
125
130
|
lib: {
|
|
@@ -135,6 +140,6 @@ export default createBaseConfig(import.meta.dirname, {
|
|
|
135
140
|
**特性:**
|
|
136
141
|
- ✅ 完整的 TypeScript 类型支持
|
|
137
142
|
- ✅ 使用 `mergeConfig` 优雅合并配置
|
|
143
|
+
- ✅ `dtsConfig` 直接配置 dts 插件选项
|
|
138
144
|
- ✅ lib 模式自动配置 `vite-plugin-dts`
|
|
139
145
|
- ✅ 默认打包为 ESM 格式
|
|
140
|
-
- ✅ 所有配置通过 `viteConfig` 统一管理,简单直观
|
package/package.json
CHANGED
package/vite.config.base.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UserConfig } from 'vite';
|
|
2
|
+
import type { PluginOptions as DtsPluginOptions } from 'vite-plugin-dts';
|
|
2
3
|
|
|
3
4
|
export interface CreateBaseConfigOptions {
|
|
4
5
|
/**
|
|
@@ -8,6 +9,11 @@ export interface CreateBaseConfigOptions {
|
|
|
8
9
|
*/
|
|
9
10
|
mode?: 'app' | 'lib';
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* vite-plugin-dts 配置(仅 lib 模式)
|
|
14
|
+
* 会与默认配置合并,可以覆盖 include、exclude 等选项
|
|
15
|
+
*/
|
|
16
|
+
dtsConfig?: Partial<DtsPluginOptions>;
|
|
11
17
|
/**
|
|
12
18
|
* 额外的 Vite 配置,会与基础配置合并
|
|
13
19
|
*/
|
package/vite.config.base.js
CHANGED
|
@@ -9,8 +9,10 @@ import dts from 'vite-plugin-dts';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @typedef {import('vite').UserConfig} UserConfig
|
|
12
|
+
* @typedef {import('vite-plugin-dts').PluginOptions} DtsPluginOptions
|
|
12
13
|
* @typedef {Object} CreateBaseConfigOptions
|
|
13
14
|
* @property {'app' | 'lib'} [mode] - 构建模式:'app' 为 Vue 应用,'lib' 为库打包
|
|
15
|
+
* @property {Partial<DtsPluginOptions>} [dtsConfig] - vite-plugin-dts 配置(仅 lib 模式),会与默认配置合并
|
|
14
16
|
* @property {UserConfig} [viteConfig] - 额外的 Vite 配置,会与基础配置合并
|
|
15
17
|
*/
|
|
16
18
|
|
|
@@ -21,7 +23,7 @@ import dts from 'vite-plugin-dts';
|
|
|
21
23
|
* @returns {import('vite').UserConfigExport} Vite 配置
|
|
22
24
|
*/
|
|
23
25
|
export function createBaseConfig(dirname, options = {}) {
|
|
24
|
-
const { mode = 'app', viteConfig = {} } = options;
|
|
26
|
+
const { mode = 'app', dtsConfig = {}, viteConfig = {} } = options;
|
|
25
27
|
|
|
26
28
|
/** @type {UserConfig} */
|
|
27
29
|
const baseConfig = {
|
|
@@ -80,12 +82,13 @@ export function createBaseConfig(dirname, options = {}) {
|
|
|
80
82
|
},
|
|
81
83
|
};
|
|
82
84
|
|
|
83
|
-
//
|
|
85
|
+
// 添加 dts 插件,用户配置会覆盖默认配置
|
|
84
86
|
baseConfig.plugins.push(
|
|
85
87
|
dts({
|
|
86
88
|
include: ['src/**/*.ts'],
|
|
87
89
|
root: dirname,
|
|
88
|
-
rollupTypes:
|
|
90
|
+
rollupTypes: false,
|
|
91
|
+
...dtsConfig,
|
|
89
92
|
}),
|
|
90
93
|
);
|
|
91
94
|
}
|