Skip to content

Commit

Permalink
pref: reuse the same targets
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Sep 23, 2024
1 parent 7ee61c4 commit ad6c783
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import process from 'node:process'
import browserslist from 'browserslist'
import { browserslistToTargets, transformStyleAttribute } from 'lightningcss'

export default function autoprefixerPreset(targets: string[] = [
export default function autoprefixerPreset(queries: string[] = [
'>= 0.25%',
'last 2 versions',
'not dead',
'not ie <= 11',
'Android >= 4.0',
'iOS >= 8',
]): Preset {
const targets = browserslistToTargets(browserslist(queries))

return {
name: 'unocss-preset-autoprefixer',
postprocess: (util) => {
Expand All @@ -21,7 +23,7 @@ export default function autoprefixerPreset(targets: string[] = [
const entries = util.entries
const { code } = transformStyleAttribute({
code: Buffer.from(entries.filter(item => !item[0].startsWith('--un')).map(x => x.join(':')).join(';')),
targets: browserslistToTargets(browserslist(targets)),
targets,
minify: true,
})

Expand Down

0 comments on commit ad6c783

Please sign in to comment.