@gsc-basic/vite-config 1.1.3 → 2.0.0
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/dist/index.d.ts +147 -148
- package/dist/index.js +4 -12
- package/package.json +11 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,179 +1,178 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
import { ConfigEnv, UserConfig, PluginOption } from 'vite';
|
|
3
|
-
import { PluginOptions } from '@intlify/unplugin-vue-i18n';
|
|
4
1
|
|
|
2
|
+
import { ConfigEnv, PluginOption, UserConfig } from "vite";
|
|
3
|
+
import { PluginOptions } from "@intlify/unplugin-vue-i18n";
|
|
4
|
+
|
|
5
|
+
//#region src/typing.d.ts
|
|
5
6
|
interface CompressOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
compressList?: Array<'gzip' | 'brotliCompress'>;
|
|
8
|
+
tarballResult?: boolean;
|
|
9
|
+
deleteOriginalAssets?: boolean;
|
|
9
10
|
}
|
|
10
11
|
interface SvgIconOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
iconDir?: string;
|
|
13
|
+
preserveColorDir?: string;
|
|
14
|
+
componentName?: string;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* 通用插件配置选项
|
|
17
18
|
* @description 所有插件共用的基础配置
|
|
18
19
|
*/
|
|
19
20
|
interface CommonPluginOptions {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 是否开启 Turbo Console
|
|
118
|
-
* @default true
|
|
119
|
-
*/
|
|
120
|
-
turboConsole?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 是否为构建模式
|
|
23
|
+
*/
|
|
24
|
+
isBuild?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 是否开启开发工具
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
devtools?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* 环境变量
|
|
32
|
+
* @description 自定义环境变量
|
|
33
|
+
*/
|
|
34
|
+
env?: Record<string, any>;
|
|
35
|
+
/**
|
|
36
|
+
* 是否注入元数据
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
injectMetadata?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* 是否开启依赖分析
|
|
42
|
+
* @default false
|
|
43
|
+
* @description 使用 vite-bundle-analyzer 分析依赖
|
|
44
|
+
*/
|
|
45
|
+
analyzer?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 是否开启UnoCSS支持
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
unocss?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 是否开启 Vue Router 自动路由支持
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
vueRouter?: boolean;
|
|
56
|
+
vueRouterOptions?: Record<string, any>;
|
|
57
|
+
/**
|
|
58
|
+
* 图标自动安装选项
|
|
59
|
+
* @description 配置图标自动安装功能
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
iconify?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 是否开启 SVG 图标支持
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
svgIcon?: boolean;
|
|
68
|
+
svgIconOptions?: SvgIconOptions;
|
|
69
|
+
/**
|
|
70
|
+
* 是否开启压缩
|
|
71
|
+
* @default false
|
|
72
|
+
* @description 支持 gzip 和 brotli 压缩
|
|
73
|
+
*/
|
|
74
|
+
compress?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* 压缩类型
|
|
77
|
+
* @default ['gzip']
|
|
78
|
+
* @description 可选的压缩类型
|
|
79
|
+
*/
|
|
80
|
+
compressOptions?: CompressOptions;
|
|
81
|
+
/**
|
|
82
|
+
* 是否开启 HTML 插件
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
html?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 是否开启国际化
|
|
88
|
+
* @default true
|
|
89
|
+
*/
|
|
90
|
+
i18n?: boolean;
|
|
91
|
+
i18nOptions?: PluginOptions;
|
|
92
|
+
/**
|
|
93
|
+
* 是否注入版权信息
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
license?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 是否开启 legacy 支持
|
|
99
|
+
* @default true
|
|
100
|
+
*/
|
|
101
|
+
legacy?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* 是否显示更新通知
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
updateNotice?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* 是否开启模拟数据
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
mock?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* 是否开启 Turbo Console
|
|
114
|
+
* @default true
|
|
115
|
+
*/
|
|
116
|
+
turboConsole?: boolean;
|
|
121
117
|
}
|
|
122
118
|
interface ProxySettingItem {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
prefix: string;
|
|
120
|
+
target: string;
|
|
121
|
+
rewrite?: boolean;
|
|
126
122
|
}
|
|
127
123
|
/**
|
|
128
124
|
* 应用配置选项类型
|
|
129
125
|
*/
|
|
130
126
|
interface ApplicationOptions extends CommonPluginOptions {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
127
|
+
appInfo: Record<string, any>;
|
|
128
|
+
base?: string;
|
|
129
|
+
serverPort?: number;
|
|
130
|
+
openPage?: boolean;
|
|
131
|
+
showProxyLog?: boolean;
|
|
132
|
+
proxyConfig?: ProxySettingItem[];
|
|
133
|
+
showPreviewProxyLog?: boolean;
|
|
134
|
+
previewProxyConfig?: ProxySettingItem[];
|
|
135
|
+
lessModifyVars?: Record<string, string>;
|
|
136
|
+
themeToken?: Record<string, string>;
|
|
137
|
+
prefixClass?: string;
|
|
138
|
+
appTitle?: string;
|
|
143
139
|
}
|
|
144
140
|
/**
|
|
145
141
|
* 应用配置定义函数类型(默认暂不支持library模式)
|
|
146
142
|
* @description 用于定义应用构建配置
|
|
147
143
|
*/
|
|
148
144
|
type DefineConfig = (config?: ConfigEnv) => Promise<{
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/** Vite 配置 */
|
|
152
|
-
vite?: UserConfig;
|
|
145
|
+
/** 应用插件配置 */application?: ApplicationOptions; /** Vite 配置 */
|
|
146
|
+
vite?: UserConfig;
|
|
153
147
|
}>;
|
|
154
|
-
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/plugins/index.d.ts
|
|
155
150
|
declare function createVitePlugins(options: ApplicationOptions): Promise<PluginOption[]>;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/config/index.d.ts
|
|
153
|
+
declare function defineConfig(config?: DefineConfig): any;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/utils/index.d.ts
|
|
156
|
+
declare function generateProjectInfo({
|
|
157
|
+
pkg
|
|
158
|
+
}?: {
|
|
159
|
+
pkg?: Record<string, string>;
|
|
161
160
|
}): string;
|
|
162
161
|
interface ProxyItem {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
prefix: string;
|
|
163
|
+
target: string;
|
|
164
|
+
rewrite?: boolean;
|
|
166
165
|
}
|
|
167
166
|
interface ProxyOptions {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
[prefix: string]: {
|
|
168
|
+
target: string;
|
|
169
|
+
changeOrigin: boolean;
|
|
170
|
+
ws: boolean;
|
|
171
|
+
rewrite: (path: string) => string;
|
|
172
|
+
secure?: boolean;
|
|
173
|
+
configure?: (proxy: any) => void;
|
|
174
|
+
};
|
|
176
175
|
}
|
|
177
176
|
declare function createProxy(list: ProxyItem[], showProxyLog?: boolean): ProxyOptions;
|
|
178
|
-
|
|
179
|
-
export { type ApplicationOptions, type CommonPluginOptions, type CompressOptions, type DefineConfig, type ProxyItem, type ProxyOptions, type ProxySettingItem, type SvgIconOptions, createProxy, createVitePlugins, defineConfig, generateProjectInfo };
|
|
177
|
+
//#endregion
|
|
178
|
+
export { type ApplicationOptions, type CommonPluginOptions, type CompressOptions, type DefineConfig, type ProxyItem, type ProxyOptions, type ProxySettingItem, type SvgIconOptions, createProxy, createVitePlugins, defineConfig, generateProjectInfo };
|
package/dist/index.js
CHANGED
|
@@ -7,16 +7,8 @@ You shall not disclose such Confidential Information and shall use it only in
|
|
|
7
7
|
accordance with the terms of the license agreement.
|
|
8
8
|
|
|
9
9
|
--- Build Info ---
|
|
10
|
-
Version: 1.1.
|
|
11
|
-
Build Time: 2026/3/
|
|
12
|
-
Build Commit:
|
|
10
|
+
Version: 1.1.3
|
|
11
|
+
Build Time: 2026/3/30 18:11:46
|
|
12
|
+
Build Commit: 0e77bf611239cf191125d0cf6cd783dd9e9fff9b
|
|
13
13
|
*/
|
|
14
|
-
import
|
|
15
|
-
<meta name="revised" content="${i}" />
|
|
16
|
-
<script>window.${r.DEPLOY_ENV_VAR_NAME} = "@DEPLOY__ENV";</script>
|
|
17
|
-
</head>`)}}}import{compression as b,tarball as I}from"vite-plugin-compression2";function f(e){let{compressList:r=[],tarballResult:t=!1,deleteOriginalAssets:i=!1}=e,n=[];return r.length>0&&n.push(b({algorithms:r,deleteOriginalAssets:i,skipIfLargerOrEqual:!1,exclude:[/\.(br)$/,/\.(gz)$/]})),t&&n.length>0&&n.push(I()),n}import m from"path";import w from"unplugin-svg-component/vite";function g({prefixClass:e="lenovo",iconDir:r="src/assets/icons",componentName:t="SvgIcon",preserveColorDir:i}){let n={treeShaking:!1};return i&&(n.preserveColor=m.resolve(process.cwd(),i)),w({iconDir:[m.resolve(process.cwd(),r)],projectType:"vue",vueVersion:3,dts:!1,componentName:t,prefix:void 0,symbolIdFormatter:(o,s)=>{let p=o.split("/");return s&&p.unshift(s),p.join("-").replace(/\.svg$/,"")},componentStyle:"width: 1em;height: 1em;fill: currentColor;vertical-align: -0.125em;",svgSpriteDomId:`${e}-svg-dom`,domInsertionStrategy:"dynamic",...n})}import{analyzer as S}from"vite-bundle-analyzer";function d(e="",r=8080){return S({reportTitle:`${e} Analyzer`,analyzerMode:"server",analyzerPort:r+200,openAnalyzer:!0})}import{webUpdateNotice as A}from"@plugin-web-update-notification/vite";function y({base:e,primaryColor:r}){return A({checkInterval:1800*1e3,checkOnWindowFocus:!0,checkImmediately:!1,checkOnLoadFileError:!0,hiddenDefaultNotification:!1,logVersion:!1,notificationConfig:{primaryColor:r},injectFileBase:e??"/"})}import v from"ansis";import{regexpMap as D}from"@gsc-basic/utils";function h({pkg:e}={}){return`/**
|
|
18
|
-
* name: ${e?.name}
|
|
19
|
-
* version: v${e?.version}
|
|
20
|
-
* author: ${typeof e?.author=="string"?e.author:e?.author&&e.author.name||""}
|
|
21
|
-
* build time: ${new Date().toLocaleString()}
|
|
22
|
-
*/`}function l(e,r=!1){let t={};for(let i of e){let{prefix:n,target:o,rewrite:s}=i;typeof s>"u"&&(s=!0);let p=D.httpsUrl.test(o);t[n]={target:o,changeOrigin:!0,ws:!0,rewrite:a=>s?a.replace(new RegExp(`^${n}`),""):a,...p?{secure:!1}:{},...r?{configure:a=>{a.on("proxyRes",(C,c)=>{console.log("proxy: ",v.red(c.originalUrl)," ===> ",v.green(C.client.servername+c.url))})}}:{}}}return t}function T(e,r){return Math.floor(Math.random()*(r-e+1))+e}function P(e){return import(e)}async function O(e){let r=[$({template:{compilerOptions:{isCustomElement:t=>t.startsWith("micro-app")}}}),k()];if(e.vueRouter)try{let{default:t}=await P("vue-router/vite");r.unshift(t(e.vueRouterOptions||{}))}catch(t){console.warn("[vite-config] `vueRouter` is enabled but `vue-router 5.x` is not installed, skip VueRouter plugin.",t)}if(e.unocss)try{let{default:t}=await P("unocss/vite");r.push(t({mode:"global"}))}catch(t){console.warn("[vite-config] `unocss` is enabled but `unocss` is not installed, skip UnoCSS plugin.",t)}if(e.iconify&&r.push(j({compiler:"vue3",autoInstall:!0})),e.injectMetadata&&r.push(V({meta:{themeToken:e.themeToken,appInfo:e.appInfo},package:{dependencies:!0,devDependencies:!0}})),e.i18n&&r.push(N({fullInstall:!0,runtimeOnly:!0,...e.i18nOptions||{}})),e.isBuild?(e.legacy&&r.push(L({targets:["> 0.2%","not dead","not op_mini all"]})),e.compress&&r.push(...f(e.compressOptions||{})),e.license&&r.push(R(h(e.appInfo))),e.updateNotice&&r.push(y({base:e.base,primaryColor:e.themeToken?.colorPrimary}))):(e.turboConsole&&r.push(_({server:{port:(e.serverPort??8080)+T(100,1e3)},launchEditor:!0})),e.devtools&&r.push(U({launchEditor:"code"})),e.qrcode&&r.push(z())),e.svgIcon){let t=e.svgIconOptions??{};r.push(g({prefixClass:e.prefixClass,iconDir:t.iconDir,preserveColorDir:t.preserveColorDir}))}return e.html&&r.push(u(e.appTitle,e.appInfo)),e.mock&&r.push(E({})),e.analyzer&&r.push(d(e.appTitle,e.serverPort)),r}import{resolve as M}from"path";import{defineConfig as F,mergeConfig as B}from"vite";import H from"autoprefixer";function q(e){return M(process.cwd(),".",e)}function x(e){return F(async r=>{let{command:t}=r,i=await e?.(r),o={...{appInfo:{},devtools:!1,injectMetadata:!0,analyzer:!1,unocss:!0,iconify:!0,svgIcon:!0,html:!0,i18n:!0,license:!0,legacy:!0,updateNotice:!0,qrcode:!1,mock:!0,turboConsole:!0},...i?.application||{}},s=t==="build",p={base:o.base??"/",root:process.cwd(),logLevel:"info",resolve:{alias:[{find:/@\//,replacement:`${q("src")}/`}]},server:{host:!0,port:o.serverPort??8080,open:o.openPage??!0,hmr:!0,proxy:l(o.proxyConfig||[],o.showProxyLog??!1),headers:{"Access-Control-Allow-Origin":"*"}},preview:{port:(o.serverPort??8080)+100,proxy:l(o.previewProxyConfig||[],o.showPreviewProxyLog??!1)},esbuild:{charset:"ascii"},build:{outDir:"dist",minify:"esbuild",reportCompressedSize:!1,chunkSizeWarningLimit:5e3,assetsInlineLimit:1024},define:{__APP_INFO__:JSON.stringify(o.appInfo??{}),"import.meta.vitest":"undefined"},css:{preprocessorOptions:{less:{modifyVars:o.lessModifyVars||{},javascriptEnabled:!0}},postcss:{plugins:s?[H()]:[]}},plugins:await O({...o,isBuild:s})};return B(p,i?.vite||{})})}function ke(e){return x(e)}export{l as createProxy,O as createVitePlugins,ke as defineConfig,h as generateProjectInfo};
|
|
14
|
+
import e from"@vitejs/plugin-vue";import t from"@vitejs/plugin-vue-jsx";import n from"@vitejs/plugin-legacy";import r from"@intlify/unplugin-vue-i18n/vite";import{mockDevServerPlugin as i}from"vite-plugin-mock-dev-server";import a from"unplugin-info/vite";import o from"unplugin-turbo-console/vite";import s from"vite-plugin-vue-devtools";import c from"unplugin-icons/vite";import{compression as l,tarball as u}from"vite-plugin-compression2";import d,{resolve as f}from"node:path";import p from"unplugin-svg-component/vite";import{analyzer as m}from"vite-bundle-analyzer";import{webUpdateNotice as h}from"@plugin-web-update-notification/vite";import{defineConfig as g,mergeConfig as _}from"vite";import v from"autoprefixer";import y from"ansis";import{regexpMap as b}from"@gsc-basic/utils";function x(e=`GSC Scaffolding`,t){return{name:`html-injection`,transformIndexHtml(n){let r=`${t.lastBuildTime}(v${t.pkg.version})`;return n.replace(`</head>`,`<title>${e}</title>\n<meta name="revised" content="${r}" />\n<script>window.${t.DEPLOY_ENV_VAR_NAME} = "@DEPLOY__ENV";<\/script>\n</head>`)}}}function S(e){let{compressList:t=[],tarballResult:n=!1,deleteOriginalAssets:r=!1}=e,i=[];return t.length>0&&i.push(l({algorithms:t,deleteOriginalAssets:r,skipIfLargerOrEqual:!1,exclude:[/\.(br)$/,/\.(gz)$/]})),n&&i.length>0&&i.push(u()),i}function C({prefixClass:e=`lenovo`,iconDir:t=`src/assets/icons`,componentName:n=`SvgIcon`,preserveColorDir:r}){let i={treeShaking:!1};return r&&(i.preserveColor=d.resolve(process.cwd(),r)),p({iconDir:[d.resolve(process.cwd(),t)],projectType:`vue`,vueVersion:3,dts:!1,componentName:n,prefix:void 0,symbolIdFormatter:(e,t)=>{let n=e.split(`/`);return t&&n.unshift(t),n.join(`-`).replace(/\.svg$/,``)},componentStyle:`width: 1em;height: 1em;fill: currentColor;vertical-align: -0.125em;`,svgSpriteDomId:`${e}-svg-dom`,domInsertionStrategy:`dynamic`,...i})}function w(e=``,t=8080){return m({reportTitle:`${e} Analyzer`,analyzerMode:`server`,analyzerPort:t+200,openAnalyzer:!0})}function T({base:e,primaryColor:t}){return h({checkInterval:1800*1e3,checkOnWindowFocus:!0,checkImmediately:!1,checkOnLoadFileError:!0,hiddenDefaultNotification:!1,logVersion:!1,notificationConfig:{primaryColor:t},injectFileBase:e??`/`})}function E(e,t){return Math.floor(Math.random()*(t-e+1))+e}function D(e){return import(e)}async function O(l){let u=[e({template:{compilerOptions:{isCustomElement:e=>e.startsWith(`micro-app`)}}}),t()];if(l.vueRouter)try{let{default:e}=await D(`vue-router/vite`);u.unshift(e(l.vueRouterOptions||{}))}catch(e){console.warn("[vite-config] `vueRouter` is enabled but `vue-router 5.x` is not installed, skip VueRouter plugin.",e)}if(l.unocss)try{let{default:e}=await D(`unocss/vite`);u.push(e({mode:`global`}))}catch(e){console.warn("[vite-config] `unocss` is enabled but `unocss` is not installed, skip UnoCSS plugin.",e)}if(l.iconify&&u.push(c({compiler:`vue3`,autoInstall:!0})),l.injectMetadata&&u.push(a({meta:{themeToken:l.themeToken,appInfo:l.appInfo},package:{dependencies:!0,devDependencies:!0}})),l.i18n&&u.push(r({fullInstall:!0,runtimeOnly:!0,...l.i18nOptions||{}})),l.isBuild?(l.legacy&&u.push(n({targets:[`> 0.2%`,`not dead`,`not op_mini all`]})),l.compress&&u.push(...S(l.compressOptions||{})),l.updateNotice&&u.push(T({base:l.base,primaryColor:l.themeToken?.colorPrimary}))):(l.turboConsole&&u.push(o({server:{port:(l.serverPort??8080)+E(100,1e3)},launchEditor:!0})),l.devtools&&u.push(s({launchEditor:`code`}))),l.svgIcon){let e=l.svgIconOptions??{};u.push(C({prefixClass:l.prefixClass,iconDir:e.iconDir,preserveColorDir:e.preserveColorDir}))}return l.html&&u.push(x(l.appTitle,l.appInfo)),l.mock&&u.push(i({})),l.analyzer&&u.push(w(l.appTitle,l.serverPort)),u}function k({pkg:e}={}){return`/**\n * version: v${e?.version}\n * author: ${typeof e?.author==`string`?e.author:e?.author&&e.author.name||``} \n * build time: ${new Date().toLocaleString()}\n */`}function A(e,t=!1){let n={};for(let r of e){let{prefix:e,target:i,rewrite:a}=r;a===void 0&&(a=!0),n[e]={target:i,changeOrigin:!0,ws:!0,rewrite:t=>a?t.replace(RegExp(`^${e}`),``):t,...b.httpsUrl.test(i)?{secure:!1}:{},...t?{configure:e=>{e.on(`proxyRes`,(e,t)=>{console.log(`proxy: `,y.red(t.originalUrl),` ===> `,y.green(e.client.servername+t.url))})}}:{}}}return n}function j(e){return f(process.cwd(),`.`,e)}function M(e){return g(async t=>{let{command:n}=t,r=await e?.(t),i={appInfo:{},devtools:!1,injectMetadata:!0,analyzer:!1,unocss:!0,iconify:!0,svgIcon:!0,html:!0,i18n:!0,license:!0,legacy:!0,updateNotice:!0,mock:!0,turboConsole:!0,...r?.application||{}},a=n===`build`;return _({base:i.base??`/`,logLevel:`info`,resolve:{alias:[{find:/@\//,replacement:`${j(`src`)}/`}]},server:{host:!0,port:i.serverPort??8080,open:i.openPage??!0,hmr:!0,proxy:A(i.proxyConfig||[],i.showProxyLog??!1),headers:{"Access-Control-Allow-Origin":`*`}},preview:{port:(i.serverPort??8080)+100,proxy:A(i.previewProxyConfig||[],i.showPreviewProxyLog??!1)},build:{outDir:`dist`,reportCompressedSize:!1,chunkSizeWarningLimit:5e3,assetsInlineLimit:1024,rolldownOptions:{output:{postBanner:i.license?k(i.appInfo):void 0}}},define:{__APP_INFO__:JSON.stringify(i.appInfo??{}),"import.meta.vitest":`undefined`},css:{preprocessorOptions:{less:{modifyVars:i.lessModifyVars||{},javascriptEnabled:!0}},postcss:{plugins:a?[v()]:[]}},plugins:await O({...i,isBuild:a})},r?.vite||{})})}function N(e){return M(e)}export{A as createProxy,O as createVitePlugins,N as defineConfig,k as generateProjectInfo};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gsc-basic/vite-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"description": "Vite Config for GSC Basic Service",
|
|
6
6
|
"author": "Lenovo SSG BASD <-GSC_Scaffolding_Support@lenovo.com>",
|
|
7
7
|
"license": "LicenseRef-Proprietary",
|
|
@@ -28,34 +28,32 @@
|
|
|
28
28
|
"./dist"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@iconify/json": "^2.2.
|
|
32
|
-
"unocss": "^66.6.
|
|
33
|
-
"vite": "^
|
|
31
|
+
"@iconify/json": "^2.2.456",
|
|
32
|
+
"unocss": "^66.6.7",
|
|
33
|
+
"vite": "^8.0.3",
|
|
34
34
|
"vue-router": "^5.0.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@intlify/unplugin-vue-i18n": "^11.0.7",
|
|
38
38
|
"@plugin-web-update-notification/vite": "^2.0.2",
|
|
39
|
-
"@vitejs/plugin-legacy": "^
|
|
39
|
+
"@vitejs/plugin-legacy": "^8.0.1",
|
|
40
40
|
"@vitejs/plugin-vue": "^6.0.4",
|
|
41
41
|
"@vitejs/plugin-vue-jsx": "^5.1.4",
|
|
42
42
|
"ansis": "^4.2.0",
|
|
43
43
|
"autoprefixer": "^10.4.27",
|
|
44
44
|
"unplugin-icons": "^23.0.1",
|
|
45
|
-
"unplugin-info": "^1.
|
|
45
|
+
"unplugin-info": "^1.3.1",
|
|
46
46
|
"unplugin-svg-component": "^0.12.4",
|
|
47
47
|
"unplugin-turbo-console": "^2.3.0",
|
|
48
|
-
"unplugin-vue-components": "^
|
|
48
|
+
"unplugin-vue-components": "^32.0.0",
|
|
49
49
|
"vite-bundle-analyzer": "^1.3.6",
|
|
50
|
-
"vite-plugin-
|
|
51
|
-
"vite-plugin-
|
|
52
|
-
"vite-plugin-
|
|
53
|
-
"vite-plugin-qrcode": "^0.3.0",
|
|
54
|
-
"vite-plugin-vue-devtools": "^8.0.6",
|
|
50
|
+
"vite-plugin-compression2": "^2.5.3",
|
|
51
|
+
"vite-plugin-mock-dev-server": "^2.1.1",
|
|
52
|
+
"vite-plugin-vue-devtools": "^8.1.1",
|
|
55
53
|
"@gsc-basic/utils": "1.3.1"
|
|
56
54
|
},
|
|
57
55
|
"scripts": {
|
|
58
|
-
"build": "
|
|
56
|
+
"build": "tsdown",
|
|
59
57
|
"outdated": "pnpm outdated",
|
|
60
58
|
"clean": "rimraf ./dist"
|
|
61
59
|
}
|