@gsc-basic/vite-config 1.0.1 → 1.0.3
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 +21 -21
- package/dist/index.d.ts +1 -4
- package/dist/index.js +7 -7
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# @gsc-basic/vite-config
|
|
2
|
-
|
|
3
|
-
> Vite Config for GSC Basic Team
|
|
4
|
-
|
|
5
|
-
**DO NOT use it in your own project if you don't know what it's for**
|
|
6
|
-
|
|
7
|
-
这是团队内部封装的 Vite 配置集合,提供一组约定的插件、别名、构建与开发相关的默认配置,并暴露一个 `defineConfig` 工厂用于在项目中快速引入和定制配置。
|
|
8
|
-
|
|
9
|
-
**主要功能**
|
|
10
|
-
|
|
11
|
-
- 集成 Vue 3、JSX 支持
|
|
12
|
-
- 支持 UnoCSS、Icons 自动安装与组件解析
|
|
13
|
-
- 可选的压缩(gzip/brotliCompress),并支持生成 tarball
|
|
14
|
-
- 内置 HTML 注入(title / meta / 部署环境变量)
|
|
15
|
-
- 可选依赖分析、构建信息注入、二维码、mock 开发服务等
|
|
16
|
-
|
|
17
|
-
**导出**
|
|
18
|
-
|
|
19
|
-
- `defineConfig`: 用于创建 Vite 配置的工厂函数,接受一个返回应用层配置和 Vite 原生配置的异步函数。
|
|
20
|
-
|
|
21
|
-
使用文档:https://gsc-basic.lenovo.com/gsc-docs/zh_CN/gsc_basic/vue/vite-config.html
|
|
1
|
+
# @gsc-basic/vite-config
|
|
2
|
+
|
|
3
|
+
> Vite Config for GSC Basic Team
|
|
4
|
+
|
|
5
|
+
**DO NOT use it in your own project if you don't know what it's for**
|
|
6
|
+
|
|
7
|
+
这是团队内部封装的 Vite 配置集合,提供一组约定的插件、别名、构建与开发相关的默认配置,并暴露一个 `defineConfig` 工厂用于在项目中快速引入和定制配置。
|
|
8
|
+
|
|
9
|
+
**主要功能**
|
|
10
|
+
|
|
11
|
+
- 集成 Vue 3、JSX 支持
|
|
12
|
+
- 支持 UnoCSS、Icons 自动安装与组件解析
|
|
13
|
+
- 可选的压缩(gzip/brotliCompress),并支持生成 tarball
|
|
14
|
+
- 内置 HTML 注入(title / meta / 部署环境变量)
|
|
15
|
+
- 可选依赖分析、构建信息注入、二维码、mock 开发服务等
|
|
16
|
+
|
|
17
|
+
**导出**
|
|
18
|
+
|
|
19
|
+
- `defineConfig`: 用于创建 Vite 配置的工厂函数,接受一个返回应用层配置和 Vite 原生配置的异步函数。
|
|
20
|
+
|
|
21
|
+
使用文档:https://gsc-basic.lenovo.com/gsc-docs/zh_CN/gsc_basic/vue/vite-config.html
|
package/dist/index.d.ts
CHANGED
|
@@ -146,9 +146,6 @@ type DefineConfig = (config?: ConfigEnv) => Promise<{
|
|
|
146
146
|
|
|
147
147
|
declare function createVitePlugins(options: ApplicationOptions): PluginOption[];
|
|
148
148
|
|
|
149
|
-
declare const OUTPUT_DIR = "dist";
|
|
150
|
-
declare const DEPLOY_ENV_NAME = "__DEPLOY_ENV_NAME__";
|
|
151
|
-
|
|
152
149
|
declare function defineConfig(config?: DefineConfig): vite.UserConfigFnPromise;
|
|
153
150
|
|
|
154
151
|
declare function generateProjectInfo(includeLogo?: boolean, { pkg }?: {
|
|
@@ -171,4 +168,4 @@ interface ProxyOptions {
|
|
|
171
168
|
}
|
|
172
169
|
declare function createProxy(list: ProxyItem[], showProxyLog?: boolean): ProxyOptions;
|
|
173
170
|
|
|
174
|
-
export { type ApplicationOptions, type CommonPluginOptions, type CompressOptions,
|
|
171
|
+
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
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import $ from"@vitejs/plugin-vue";import
|
|
2
|
-
<meta name="revised" content="${
|
|
3
|
-
<script>window.${
|
|
4
|
-
</head>`)}}}import{compression as
|
|
1
|
+
import $ from"@vitejs/plugin-vue";import D from"@vitejs/plugin-vue-jsx";import L from"@vitejs/plugin-legacy";import z from"@intlify/unplugin-vue-i18n/vite";import E from"vite-plugin-banner";import{qrcode as N}from"vite-plugin-qrcode";import{mockDevServerPlugin as k}from"vite-plugin-mock-dev-server";import V from"unplugin-info/vite";import j from"unplugin-turbo-console/vite";import T from"vite-plugin-vue-devtools";import M from"unocss/vite";import R from"unplugin-icons/vite";function c(e="GSC Scaffolding",r){return{name:"html-injection",transformIndexHtml(t){let i=`${r.lastBuildTime}(v${r.pkg.version})`;return t.replace("</head>",`<title>${e}</title>
|
|
2
|
+
<meta name="revised" content="${i}" />
|
|
3
|
+
<script>window.${r.DEPLOY_ENV_VAR_NAME} = "@DEPLOY__ENV";</script>
|
|
4
|
+
</head>`)}}}import{compression as _,tarball as O}from"vite-plugin-compression2";function m(e){let{compressList:r=[],tarballResult:t=!1,deleteOriginalAssets:i=!1}=e,n=[];return r.length>0&&n.push(_({algorithms:r,deleteOriginalAssets:i,skipIfLargerOrEqual:!1,exclude:[/\.(br)$/,/\.(gz)$/]})),t&&n.length>0&&n.push(O()),n}import u from"path";import I 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=u.resolve(process.cwd(),i)),I({iconDir:[u.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"})}import{analyzer as b}from"vite-bundle-analyzer";function d(e="",r=8080){return b({reportTitle:`${e} Analyzer`,analyzerMode:"server",analyzerPort:r+200,openAnalyzer:!0})}import{webUpdateNotice as w}from"@plugin-web-update-notification/vite";function y({base:e,primaryColor:r}){return w({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 S}from"@gsc-basic/utils";var A=` / /
|
|
5
5
|
/ / ___ __ ___ ___
|
|
6
6
|
/ / //___) ) // ) ) // ) ) || / / // ) )
|
|
7
7
|
/ / // // / / // / / || / / // / /
|
|
8
|
-
/ /____/ / ((____ // / / ((___/ / ||/ / ((___/ /`;function
|
|
9
|
-
${e?`${
|
|
8
|
+
/ /____/ / ((____ // / / ((___/ / ||/ / ((___/ /`;function h(e=!0,{pkg:r}={}){return`/**
|
|
9
|
+
${e?`${A}
|
|
10
10
|
`:""} * name: ${r?.name}
|
|
11
11
|
* version: v${r?.version}
|
|
12
12
|
* description: ${r?.description}
|
|
13
13
|
* author: ${typeof r?.author=="string"?r.author:r?.author&&r.author.name||""}
|
|
14
|
-
*/`}function
|
|
14
|
+
*/`}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=S.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,f)=>{console.log("proxy: ",v.red(f.originalUrl)," ===> ",v.green(C.client.servername+f.url))})}}:{}}}return t}function U(e,r){return Math.floor(Math.random()*(r-e+1))+e}function x(e){let r=[$({template:{compilerOptions:{isCustomElement:t=>t.startsWith("micro-app")}}}),D()];if(e.unocss&&r.push(M({mode:"global"})),e.iconify&&r.push(R({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(z({fullInstall:!0,runtimeOnly:!0})),e.isBuild?(e.legacy&&r.push(L({targets:["> 0.2%","not dead","not op_mini all"]})),e.compress&&r.push(...m(e.compressOptions||{})),e.license&&r.push(E(h(!0,e.appInfo))),e.updateNotice&&r.push(y({base:e.base,primaryColor:e.themeToken?.colorPrimary}))):(e.turboConsole&&r.push(j({server:{port:(e.serverPort??8080)+U(100,1e3)},launchEditor:!0})),e.devtools&&r.push(T({launchEditor:"code"})),e.qrcode&&r.push(N())),e.svgIcon){let t=e.svgIconOptions??{};r.push(g({prefixClass:e.prefixClass,iconDir:t.iconDir,preserveColorDir:t.preserveColorDir}))}return e.html&&r.push(c(e.appTitle,e.appInfo)),e.mock&&r.push(k({})),e.analyzer&&r.push(d(e.appTitle,e.serverPort)),r}import{resolve as F}from"path";import{defineConfig as B,mergeConfig as H}from"vite";import q from"autoprefixer";function W(e){return F(process.cwd(),".",e)}function P(e){return B(async r=>{let{command:t}=r,i=await e?.(r),o={...{appInfo:{},devtools:!1,injectMetadata:!0,analyzer:!0,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:`${W("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?[q()]:[]}},plugins:x({...o,isBuild:s})};return H(p,i?.vite||{})})}function ze(e){return P(e)}export{l as createProxy,x as createVitePlugins,ze as defineConfig,h 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": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Vite Config for GSC Basic Service",
|
|
6
6
|
"author": "wangll47 <wangll47@lenovo.com>",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"vite": "^7.2.6"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@intlify/unplugin-vue-i18n": "^11.0.
|
|
36
|
+
"@intlify/unplugin-vue-i18n": "^11.0.3",
|
|
37
37
|
"@plugin-web-update-notification/vite": "^2.0.2",
|
|
38
38
|
"@vitejs/plugin-legacy": "^7.2.1",
|
|
39
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
39
|
+
"@vitejs/plugin-vue": "^6.0.3",
|
|
40
40
|
"@vitejs/plugin-vue-jsx": "^5.1.2",
|
|
41
41
|
"ansis": "^4.2.0",
|
|
42
|
-
"autoprefixer": "^10.4.
|
|
42
|
+
"autoprefixer": "^10.4.23",
|
|
43
43
|
"unplugin-icons": "^22.5.0",
|
|
44
44
|
"unplugin-info": "^1.2.4",
|
|
45
45
|
"unplugin-svg-component": "^0.12.4",
|
|
46
46
|
"unplugin-turbo-console": "^2.3.0",
|
|
47
47
|
"unplugin-vue-components": "^30.0.0",
|
|
48
|
-
"vite-bundle-analyzer": "^1.2
|
|
48
|
+
"vite-bundle-analyzer": "^1.3.2",
|
|
49
49
|
"vite-plugin-banner": "^0.8.1",
|
|
50
50
|
"vite-plugin-compression2": "^2.4.0",
|
|
51
51
|
"vite-plugin-mock-dev-server": "^2.0.5",
|