Skip to content

Commit d0c629b

Browse files
committed
revert: b503b58
target 从 .browserslistrc 中生成
1 parent 97e194a commit d0c629b

22 files changed

Lines changed: 124 additions & 20 deletions

.browserslistrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: 2024-2025 caixw
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
>5%, last 2 versions, not dead

apps/admin/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"@cmfx/core": "workspace:*",
3030
"@iconify/json": "catalog:",
3131
"@solidjs/router": "catalog:",
32+
"browserslist": "catalog:",
33+
"browserslist-to-esbuild": "catalog:",
3234
"echarts": "catalog:",
3335
"tailwindcss": "catalog:",
3436
"solid-js": "catalog:",

apps/admin/vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from 'node:path';
66
//import basicSsl from '@vitejs/plugin-basic-ssl';
77
import { about } from '@cmfx/vite-plugin-about';
88
import tailwindcss from '@tailwindcss/vite';
9+
import browserslistToEsbuild from 'browserslist-to-esbuild';
910
import Icons from 'unplugin-icons/vite';
1011
import { defineConfig } from 'vite';
1112
import solidPlugin from 'vite-plugin-solid';
@@ -23,6 +24,7 @@ export default defineConfig(({ mode }) => {
2324
},
2425

2526
build: {
27+
target: browserslistToEsbuild(),
2628
sourcemap: true,
2729
rolldownOptions: {
2830
output: {

apps/docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"@tailwindcss/vite": "catalog:",
4242
"@types/node": "catalog:",
4343
"autoprefixer": "catalog:",
44+
"browserslist": "catalog:",
45+
"browserslist-to-esbuild": "catalog:",
4446
"typescript": "catalog:",
4547
"unplugin-icons": "catalog:",
4648
"vite": "catalog:",

apps/docs/src/main.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ function InternalApp(props: RouteSectionProps): JSX.Element {
104104
title={options.title}
105105
actions={
106106
<>
107-
<Drawer.ToggleButton square kind="flat" drawer={docsRef()} />
108-
<Drawer.ToggleButton square kind="flat" drawer={demoRef()} />
109-
<Drawer.ToggleButton square kind="flat" drawer={themeRef()} />
107+
<Drawer.ToggleButton kind="flat" drawer={docsRef()} />
108+
<Drawer.ToggleButton kind="flat" drawer={demoRef()} />
109+
<Drawer.ToggleButton kind="flat" drawer={themeRef()} />
110110

111111
<Dropdown.Root
112112
trigger="hover"
@@ -125,9 +125,7 @@ function InternalApp(props: RouteSectionProps): JSX.Element {
125125
</Dropdown.Root>
126126

127127
<Dropdown.Root
128-
ref={el => {
129-
themeDropdown = el;
130-
}}
128+
ref={el => (themeDropdown = el)}
131129
trigger="hover"
132130
multiple
133131
value={modeValues()}
@@ -217,13 +215,7 @@ function NotFound(): JSX.Element {
217215
<Button.Root palette="primary" type="a" href="/">
218216
{l.t('_d.error.backHome')}
219217
</Button.Root>
220-
<Button.Root
221-
palette="primary"
222-
type="button"
223-
onclick={() => {
224-
nav(-1);
225-
}}
226-
>
218+
<Button.Root palette="primary" type="button" onclick={() => nav(-1)}>
227219
{l.t('_d.error.backPrev')}
228220
</Button.Root>
229221
</div>

apps/docs/src/theme/builder/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function buildRoute(path: string, setDrawer: Setter<Drawer.RootRef | unde
3131
const [act] = useOptions();
3232

3333
const t = useTheme();
34-
const schemeFA = new Form.ObjectAccessor<Scheme>(convertSchemeVar2Color(unwrap(t.scheme)!));
34+
const schemeFA = new Form.ObjectAccessor<Scheme>(convertSchemeVar2Color(unwrap(t.scheme)));
3535

3636
createEffect(() => {
3737
act.setTitle(l.t('_d.theme.builder'));

apps/docs/src/theme/builder/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
import { palettes, type Scheme } from '@cmfx/components';
66

77
/**
8-
* 将参数 s 中的颜色变量转换为实际颜色值
8+
* 将参数 s 中的颜色变量转换为实际颜色值并返回新的对象
99
*/
1010
export function convertSchemeVar2Color(s: Scheme): Scheme {
1111
// 主题无法引用非全局的 CSS 变量。所以这里统一从全局解析变量的值
1212
const style = window.getComputedStyle(document.documentElement);
1313

14+
const ret = {} as Scheme;
1415
for (const p of palettes) {
1516
const colorVal = s[p];
1617
if (colorVal.startsWith('var(--')) {
1718
// 值是变量,需要计算其真实的值。
18-
s[p] = style.getPropertyValue(colorVal.slice(4, -1));
19+
ret[p] = style.getPropertyValue(colorVal.slice(4, -1));
1920
}
2021
}
2122

22-
return s;
23+
return ret;
2324
}

apps/docs/vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import path from 'node:path';
66
import { api } from '@cmfx/vite-plugin-api';
77
import tailwindcss from '@tailwindcss/vite';
8+
import browserslistToEsbuild from 'browserslist-to-esbuild';
89
import Icons from 'unplugin-icons/vite';
910
import { defineConfig } from 'vite';
1011
import solidPlugin from 'vite-plugin-solid';
@@ -23,6 +24,7 @@ export default defineConfig(({ mode }) => {
2324
},
2425

2526
build: {
27+
target: browserslistToEsbuild(),
2628
minify: true,
2729
outDir: '../../docs',
2830
rollupOptions: {

build/vite-plugin-about/vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { defineConfig } from 'vite';
66
import dts from 'vite-plugin-dts';
77

8-
import { buildPostBanner, vitePluginCopyFile } from '../vite.config.common';
8+
import { buildPostBanner, pluginTarget, vitePluginCopyFile } from '../vite.config.common';
99
import pkg from './package.json' with { type: 'json' };
1010

1111
// https://vitejs.dev/config/
@@ -21,6 +21,7 @@ export default defineConfig({
2121
],
2222

2323
build: {
24+
target: pluginTarget(),
2425
minify: true,
2526
outDir: './lib',
2627
lib: {

build/vite-plugin-api/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { defineConfig } from 'vite';
66
import dts from 'vite-plugin-dts';
77

8-
import { buildPostBanner, vitePluginCopyFile } from '../vite.config.common';
8+
import { buildPostBanner, pluginTarget, vitePluginCopyFile } from '../vite.config.common';
99
import pkg from './package.json' with { type: 'json' };
1010

1111
// https://vitejs.dev/config/
@@ -23,7 +23,7 @@ export default defineConfig({
2323
build: {
2424
minify: true,
2525
outDir: './lib',
26-
target: 'ESNext',
26+
target: pluginTarget(),
2727
lib: {
2828
entry: {
2929
index: './src/index.ts',

0 commit comments

Comments
 (0)