Skip to content

Commit

Permalink
chore!: 在 package.json 中统一管理 browserslist
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Aug 29, 2023
1 parent 6af2e41 commit 9d2131d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,13 @@
},
"repository": {
"url": "https://github.com/dishait/tov-template"
}
},
"browserslist": [
">= 0.25%",
"last 2 versions",
"not dead",
"not ie <= 11",
"Android >= 4.0",
"iOS >= 8"
]
}
15 changes: 7 additions & 8 deletions presets/autoprefixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import type { Preset } from 'unocss'
import browserslist from 'browserslist'
import { browserslistToTargets, transformStyleAttribute } from 'lightningcss'

const { loadConfig: browserslistLoadConfig } = browserslist

const defaultTargets = browserslistLoadConfig({ path: process.cwd() }) || [
'last 2 versions and not dead, > 0.3%, Firefox ESR',
]

export default function autoprefixerPreset(
targets: string[] = [
'>= 0.25%',
'last 2 versions',
'not dead',
'not ie <= 11',
'Android >= 4.0',
'iOS >= 8',
],
targets?: string[] = defaultTargets,
): Preset {
return {
name: 'unocss-preset-autoprefixer',
Expand Down
11 changes: 1 addition & 10 deletions presets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,7 @@ export default function () {
* 兼容不支持 esmModule 的浏览器
* https://www.npmjs.com/package/@vitejs/plugin-legacy
*/
Legacy({
targets: [
'>= 0.25%',
'last 2 versions',
'not dead',
'not ie <= 11',
'Android >= 4.0',
'iOS >= 8',
],
}),
Legacy(),
/**
* 环境变量类型提示
* https://github.com/dishait/vite-plugin-env-types
Expand Down

0 comments on commit 9d2131d

Please sign in to comment.