fe-stack 0.0.3 → 0.0.4
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/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fe-stack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "共享的配置文件集合,用于 Vite、Tailwind、Biome、Prettier 和 TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./vite.config.base": {
|
|
8
|
-
"types": "./vite.config.base.ts",
|
|
9
|
-
"import": "./vite.config.base.
|
|
8
|
+
"types": "./vite.config.base.d.ts",
|
|
9
|
+
"import": "./vite.config.base.js"
|
|
10
10
|
},
|
|
11
11
|
"./tsconfig.*.json": "./tsconfig.*.json",
|
|
12
12
|
"./biome.json": "./biome.json",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"tailwind.config.js",
|
|
20
20
|
"tsconfig.app.json",
|
|
21
21
|
"tsconfig.node.json",
|
|
22
|
-
"vite.config.base.
|
|
22
|
+
"vite.config.base.js",
|
|
23
|
+
"vite.config.base.d.ts",
|
|
23
24
|
"README.md"
|
|
24
25
|
],
|
|
25
26
|
"keywords": [
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UserConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
export interface CreateBaseConfigOptions {
|
|
4
|
+
/**
|
|
5
|
+
* 构建模式
|
|
6
|
+
* - 'app': Vue 应用模式,包含 Vue Router、Auto Import 等
|
|
7
|
+
* - 'lib': 库打包模式,配置 vite-plugin-dts
|
|
8
|
+
*/
|
|
9
|
+
mode?: 'app' | 'lib';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 额外的 Vite 配置,会与基础配置合并
|
|
13
|
+
*/
|
|
14
|
+
viteConfig?: UserConfig;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 创建基础 Vite 配置
|
|
19
|
+
* @param dirname - 项目根目录路径(通常使用 import.meta.dirname)
|
|
20
|
+
* @param options - 配置选项
|
|
21
|
+
* @returns Vite 配置
|
|
22
|
+
*/
|
|
23
|
+
export function createBaseConfig(
|
|
24
|
+
dirname: string,
|
|
25
|
+
options?: CreateBaseConfigOptions,
|
|
26
|
+
): import('vite').UserConfigExport;
|
|
@@ -4,22 +4,27 @@ import vue from '@vitejs/plugin-vue';
|
|
|
4
4
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
5
5
|
import Components from 'unplugin-vue-components/vite';
|
|
6
6
|
import VueRouter from 'unplugin-vue-router/vite';
|
|
7
|
-
import type { UserConfig } from 'vite';
|
|
8
7
|
import { defineConfig, mergeConfig } from 'vite';
|
|
9
8
|
import dts from 'vite-plugin-dts';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import('vite').UserConfig} UserConfig
|
|
12
|
+
* @typedef {Object} CreateBaseConfigOptions
|
|
13
|
+
* @property {'app' | 'lib'} [mode] - 构建模式:'app' 为 Vue 应用,'lib' 为库打包
|
|
14
|
+
* @property {UserConfig} [viteConfig] - 额外的 Vite 配置,会与基础配置合并
|
|
15
|
+
*/
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* 创建基础 Vite 配置
|
|
19
|
+
* @param {string} dirname - 项目根目录路径
|
|
20
|
+
* @param {CreateBaseConfigOptions} [options] - 配置选项
|
|
21
|
+
* @returns {import('vite').UserConfigExport} Vite 配置
|
|
22
|
+
*/
|
|
23
|
+
export function createBaseConfig(dirname, options = {}) {
|
|
20
24
|
const { mode = 'app', viteConfig = {} } = options;
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
/** @type {UserConfig} */
|
|
27
|
+
const baseConfig = {
|
|
23
28
|
resolve: {
|
|
24
29
|
alias: {
|
|
25
30
|
'@': path.resolve(dirname, './src'),
|
|
@@ -36,11 +41,19 @@ export function createBaseConfig(
|
|
|
36
41
|
],
|
|
37
42
|
},
|
|
38
43
|
plugins: [],
|
|
44
|
+
worker: {
|
|
45
|
+
format: 'es',
|
|
46
|
+
rollupOptions: {
|
|
47
|
+
output: {
|
|
48
|
+
format: 'es',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
39
52
|
};
|
|
40
53
|
|
|
41
54
|
// App mode: 包含 Vue 全家桶
|
|
42
55
|
if (mode === 'app') {
|
|
43
|
-
baseConfig.plugins
|
|
56
|
+
baseConfig.plugins.push(
|
|
44
57
|
VueRouter({
|
|
45
58
|
dts: './src/typed-router.d.ts',
|
|
46
59
|
}),
|
|
@@ -68,7 +81,7 @@ export function createBaseConfig(
|
|
|
68
81
|
};
|
|
69
82
|
|
|
70
83
|
// 默认添加 dts 插件
|
|
71
|
-
baseConfig.plugins
|
|
84
|
+
baseConfig.plugins.push(
|
|
72
85
|
dts({
|
|
73
86
|
include: ['src/**/*.ts'],
|
|
74
87
|
root: dirname,
|