@moluoxixi/vite-config 0.0.26 → 0.0.29

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/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { createViteConfig, getViteConfig } from './src/index.ts';
2
+ export default createViteConfig;
3
+ export { wrapperEnv } from './src/_utils/index.ts';
4
+ export { getViteConfig, createViteConfig as ViteConfig };
@@ -0,0 +1,188 @@
1
+ import { visualizer } from 'rollup-plugin-visualizer';
2
+ import { Options as unpluginAutoImportOptions } from 'unplugin-auto-import/types';
3
+ import { Options as unpluginVueComponentsOptions } from 'unplugin-vue-components/types';
4
+ import { ConfigEnv, PluginOption, UserConfig } from 'vite';
5
+ import { default as importToCDN } from 'vite-plugin-cdn-import';
6
+ import { UserOptions as PagesOptions } from 'vite-plugin-pages';
7
+ import { Options as VitePWAOptions } from 'vite-plugin-pwa';
8
+ type ViteCompressionModule = typeof import('vite-plugin-compression');
9
+ type ViteImageminModule = typeof import('vite-plugin-imagemin');
10
+ export type CompressionOptions = ViteCompressionModule extends {
11
+ default: infer F;
12
+ } ? F extends (...args: any[]) => any ? Parameters<F>[0] : never : never;
13
+ export type ImageminOptions = ViteImageminModule extends {
14
+ default: infer F;
15
+ } ? F extends (...args: any[]) => any ? Parameters<F>[0] : never : never;
16
+ export type CompressionPlugin = (options?: CompressionOptions) => PluginOption;
17
+ export type ImageminPlugin = (options?: ImageminOptions) => PluginOption;
18
+ export type QiankunPlugin = (name: string, options?: {
19
+ useDevMode?: boolean;
20
+ }) => PluginOption;
21
+ export type CDNOptions = Parameters<typeof importToCDN>[0] & {
22
+ /**
23
+ * CDN的基本url
24
+ */
25
+ baseUrl?: string;
26
+ /**
27
+ * dev环境是否启用CDN
28
+ */
29
+ enableInDevMode?: boolean;
30
+ };
31
+ export type VisualizerOptions = Parameters<typeof visualizer>[0];
32
+ /**
33
+ * 插件配置类型,仅在 ModeConfig 中使用
34
+ */
35
+ export interface PluginConfig {
36
+ /**
37
+ * AutoImport配置,true表示使用默认配置,对象表示覆盖默认配置
38
+ */
39
+ autoImport?: boolean | unpluginAutoImportOptions;
40
+ /**
41
+ * Components配置,true表示使用默认配置,对象表示覆盖默认配置
42
+ */
43
+ autoComponent?: boolean | (unpluginVueComponentsOptions & {
44
+ /**
45
+ * 需要排除的element-plus组件
46
+ */
47
+ elementExcludes?: string[];
48
+ /**
49
+ * 除resolve规则外,额外需要引入的组件所需匹配规则
50
+ */
51
+ globs?: string[];
52
+ });
53
+ /**
54
+ * 压缩配置,true表示使用默认配置,对象表示覆盖默认配置
55
+ */
56
+ compression?: boolean | CompressionOptions;
57
+ /**
58
+ * 图片压缩配置,true表示使用默认配置,对象表示覆盖默认配置
59
+ */
60
+ imagemin?: boolean | ImageminOptions;
61
+ /**
62
+ * CDN配置,true表示使用默认配置,对象表示覆盖默认配置
63
+ */
64
+ cdn?: boolean | CDNOptions;
65
+ /**
66
+ * 包预览配置,true表示使用默认配置,对象表示覆盖默认配置
67
+ */
68
+ visualizer?: boolean | VisualizerOptions;
69
+ /**
70
+ * 自动路由配置,true表示使用默认配置,对象表示覆盖默认配置
71
+ */
72
+ autoRoutes?: boolean | AutoRoutesConfig;
73
+ /**
74
+ * 页面路由配置(vite-plugin-pages),true表示使用默认配置,对象表示覆盖默认配置
75
+ */
76
+ pageRoutes?: boolean | PagesOptions;
77
+ /**
78
+ * 是否启用vue-devtools
79
+ */
80
+ devtools?: boolean;
81
+ /**
82
+ * 项目端口
83
+ */
84
+ port?: number;
85
+ /**
86
+ * 是否在npm run dev时,自动打开浏览器
87
+ */
88
+ open?: boolean;
89
+ /**
90
+ * dev环境是否启用qiankun
91
+ */
92
+ qiankunDevMode?: boolean;
93
+ /**
94
+ * 是否启用qiankun
95
+ */
96
+ qiankun?: boolean;
97
+ /**
98
+ * 命名空间,启用后在非dev环境下的envSystemCode将等于此值
99
+ */
100
+ namespace?: string;
101
+ /**
102
+ * 是否在打包时,删除console和debugger
103
+ */
104
+ dropConsole?: boolean;
105
+ /**
106
+ * PWA配置,true表示使用默认配置,对象表示覆盖默认配置
107
+ */
108
+ pwa?: boolean | VitePWAOptions;
109
+ /**
110
+ * Code Inspector配置,true表示使用默认配置,对象表示覆盖默认配置
111
+ */
112
+ codeInspector?: boolean | Parameters<typeof import('code-inspector-plugin').codeInspectorPlugin>[0];
113
+ /**
114
+ * 是否是vitepress
115
+ */
116
+ vitepress?: boolean;
117
+ /**
118
+ * 是否是vue
119
+ */
120
+ vue?: boolean;
121
+ /**
122
+ * 是否是react
123
+ */
124
+ react?: boolean;
125
+ /**
126
+ * 项目标题
127
+ */
128
+ appTitle?: string;
129
+ /**
130
+ * 项目code
131
+ */
132
+ appCode?: string;
133
+ }
134
+ export interface ModeConfig extends PluginConfig {
135
+ }
136
+ export interface objRouteConfig {
137
+ glob: string | string[];
138
+ baseRoute?: {
139
+ path: string;
140
+ name: string;
141
+ meta?: any;
142
+ children?: any[];
143
+ } | string;
144
+ }
145
+ export interface RouteConfig {
146
+ [prefix: string]: string | string[] | objRouteConfig;
147
+ }
148
+ export interface AutoRoutesConfig {
149
+ /**
150
+ * 路由配置
151
+ */
152
+ routeConfig: RouteConfig;
153
+ /**
154
+ * 虚拟模块ID
155
+ */
156
+ virtualModuleId?: string;
157
+ /**
158
+ * 声明文件路径,true表示使用默认路径,false表示不生成声明文件
159
+ */
160
+ dts?: string | boolean;
161
+ /**
162
+ * 项目根目录路径
163
+ */
164
+ root?: string;
165
+ }
166
+ export interface Config extends PluginConfig {
167
+ /**
168
+ * 根目录
169
+ */
170
+ rootPath: string;
171
+ /**
172
+ * 环境配置
173
+ */
174
+ mode?: {
175
+ base?: ModeConfig;
176
+ development?: ModeConfig;
177
+ production?: ModeConfig;
178
+ };
179
+ viteConfig?: UserConfig | ((mode: ConfigEnv) => UserConfig);
180
+ }
181
+ export type ViteConfigType = Config | ((mode: ConfigEnv) => Config);
182
+ export type PluginType = PluginOption & {
183
+ name: string;
184
+ };
185
+ export interface PluginMap {
186
+ [key: string]: PluginOption;
187
+ }
188
+ export {};
@@ -0,0 +1,22 @@
1
+ import { objType } from '../../../_types/index.ts';
2
+ export declare function isDevFn(mode: string): boolean;
3
+ export declare function isProdFn(mode: string): boolean;
4
+ /**
5
+ * Whether to generate package preview
6
+ */
7
+ export declare function isReportMode(): boolean;
8
+ /**
9
+ * 将环境变量中的字符串值转换为对应的 JavaScript 数据类型
10
+ */
11
+ export declare function wrapperEnv(env: Record<string, string>): objType;
12
+ /**
13
+ * Get the environment variables starting with the specified prefix
14
+ * @param match prefix
15
+ * @param confFiles ext
16
+ */
17
+ export declare function getEnvConfig(match?: string, confFiles?: string[]): {};
18
+ /**
19
+ * Get user root directory
20
+ * @param dir file path
21
+ */
22
+ export declare function getRootPath(...dir: string[]): string;
@@ -0,0 +1 @@
1
+ export * from './getEnv.ts';
@@ -0,0 +1 @@
1
+ export declare const modules: any;
@@ -0,0 +1,6 @@
1
+ import { ConfigEnv } from 'vite';
2
+ import { ViteConfigType } from './_types/index.ts';
3
+ declare function getViteConfig(Config: ViteConfigType, params?: ConfigEnv): Promise<Record<string, any>>;
4
+ declare function createViteConfig(Config: ViteConfigType): import('vite').UserConfigFnPromise;
5
+ export { createViteConfig, getViteConfig, };
6
+ export default createViteConfig;
@@ -0,0 +1,10 @@
1
+ export default function addScopedAndReplacePrefixPlugin({ prefixScoped, oldPrefix, newPrefix, useDevMode, }: {
2
+ prefixScoped?: string | undefined;
3
+ oldPrefix?: string | undefined;
4
+ newPrefix?: string | undefined;
5
+ useDevMode?: boolean | undefined;
6
+ }): {
7
+ name: string;
8
+ configResolved(config: any): void;
9
+ transform(code?: string, id?: string): string;
10
+ };
@@ -0,0 +1,10 @@
1
+ import { Plugin } from 'vite';
2
+ export interface QiankunCssInjectOptions {
3
+ target?: string;
4
+ include?: string | string[];
5
+ exclude?: string | string[];
6
+ cssInclude?: string | string[];
7
+ cssExclude?: string | string[];
8
+ appId?: string;
9
+ }
10
+ export default function qiankunCssInject(options?: QiankunCssInjectOptions): Plugin | false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/vite-config",
3
- "version": "0.0.26",
3
+ "version": "0.0.29",
4
4
  "description": "ViteConfig 组件",
5
5
  "sideEffects": [
6
6
  "*.css",
@@ -8,15 +8,16 @@
8
8
  ],
9
9
  "peerDependencies": {
10
10
  "vite": "6.2.4",
11
- "vue": "3.5.19"
11
+ "vue": "3.5.18"
12
12
  },
13
13
  "dependencies": {
14
14
  "dotenv": "16.6.1",
15
- "@tailwindcss/postcss": "4.1.5",
15
+ "@tailwindcss/postcss": "4.1.11",
16
+ "@vitejs/plugin-react": "4.7.0",
16
17
  "@vitejs/plugin-vue": "5.2.4",
17
18
  "@vitejs/plugin-vue-jsx": "4.2.0",
18
19
  "autoprefixer": "10.4.21",
19
- "code-inspector-plugin": "1.2.10",
20
+ "code-inspector-plugin": "1.3.3",
20
21
  "rollup-plugin-visualizer": "5.14.0",
21
22
  "unplugin-auto-import": "19.3.0",
22
23
  "unplugin-vue-components": "28.8.0",
@@ -24,8 +25,8 @@
24
25
  "vite-plugin-compression": "0.5.1",
25
26
  "vite-plugin-html": "3.2.2",
26
27
  "vite-plugin-imagemin": "0.6.1",
27
- "vite-plugin-pages": "0.33.1",
28
- "vite-plugin-pwa": "1.1.0",
28
+ "vite-plugin-pages": "0.33.2",
29
+ "vite-plugin-pwa": "1.2.0",
29
30
  "vite-plugin-qiankun": "1.0.15",
30
31
  "vite-plugin-vue-devtools": "7.7.7",
31
32
  "lodash-es": "4.17.21",
@@ -36,6 +37,7 @@
36
37
  "access": "public"
37
38
  },
38
39
  "license": "MIT",
40
+ "main": "lib/index.cjs",
39
41
  "module": "es/index.mjs",
40
42
  "types": "es/index.d.ts",
41
43
  "exports": {
@@ -45,10 +47,20 @@
45
47
  "default": "./es/index.mjs"
46
48
  }
47
49
  },
50
+ "./lib": {
51
+ "require": {
52
+ "types": "./lib/index.d.ts",
53
+ "default": "./lib/index.cjs"
54
+ }
55
+ },
48
56
  ".": {
49
57
  "import": {
50
58
  "types": "./es/index.d.ts",
51
59
  "default": "./es/index.mjs"
60
+ },
61
+ "require": {
62
+ "types": "./lib/index.d.ts",
63
+ "default": "./lib/index.cjs"
52
64
  }
53
65
  }
54
66
  }